Packages
prom_ex
1.12.0
1.12.0
1.11.0
1.10.0
1.9.0
1.8.0
1.7.1
1.7.0
retired
1.6.0
1.5.0
1.4.1
1.4.0
1.3.0
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
0.1.15-beta
0.1.14-beta
0.1.13-beta
0.1.12-beta
0.1.11-alpha
0.1.10-alpha
0.1.9-alpha
0.1.8-alpha
0.1.7-alpha
0.1.6-alpha
0.1.5-alpha
0.1.4-alpha
0.1.3-alpha
0.1.2-alpha
0.1.1-alpha
0.1.0-alpha
Prometheus metrics and Grafana dashboards for all of your favorite Elixir libraries
Current section
Files
Jump to
Current section
Files
guides/howtos/Running Multiple Agents.md
# Running Multiple Agents
Suppose you want to send your metrics to two separate Prometheus databases, and define two separate sets of dashboards - one for the ops team, and one for the business team.
You can do this by creating two PromEx configurations.
To generate distinct PromEx modules:
```sh
mix prom_ex.gen.config -d ops -m PromExOps
mix prom_ex.gen.config -d biz -m PromExBiz
```
Each PromEx config will run its own Grafana Agent. You need to configure `working_directory`, `agent_port` and `grpc_port` to make sure they don't collide:
```elixir
config :my_app, MyApp.PromExOps,
grafana_agent: [
working_directory: System.fetch_env!("RELEASE_TMP") <> "/grafana-ops",
config_opts: [
...
agent_port: 4040,
grpc_port: 9040
]
]
config :my_app, MyApp.PromExBiz,
grafana_agent: [
working_directory: System.fetch_env!("RELEASE_TMP") <> "/grafana-biz",
config_opts: [
...
agent_port: 4041,
grpc_port: 9041
]
]
```
Add each module to your application's supervisor per the directions in the generated PromEx file.
## Endpoints
You can configure each agent to scrape the same set of metrics:
```elixir
# endpoint.ex
plug PromEx.Plug, prom_ex_module: MyApp.PromExOps
# in mix config, set `metrics_server_path: "/metrics"`
```
or define separate endpoints:
```elixir
plug PromEx.Plug, prom_ex_module: MyApp.PromExOps, path: "/metrics/ops"
plug PromEx.Plug, prom_ex_module: MyApp.PromExBiz, path: "/metrics/biz"
```