prom_ex icon indicating copy to clipboard operation
prom_ex copied to clipboard

Run multiple Grafana Agent processes

Open patmaddox opened this issue 3 years ago • 3 comments

Change description

  • Permit parallel grafana agent downloader processes
  • Configure grafana agent gRPC port
  • Add -m option to generator to specify PromEx module name

This allows us to configure multiple PromEx processes within our own application.

What problem does this solve?

We want to record metrics and publish dashboards to multiple sources (e.g. one for ops team, and one for biz team).

Example usage

Configure multiple PromEx processes and add them each to the supervisor:

  config :my_app, Core.PromExBiz,
    ...
    grafana: [
      host: "http://localhost:3000",
      ...
      folder_name: "myapp-biz"
    ],
    grafana_agent: [
      working_directory: Path.expand(".grafana_biz"),
      config_opts: [
        metrics_server_path: "/metrics/biz",
        ...
        instance: "dev-biz",
        prometheus_url: "http://prometheus-biz:9090/api/v1/write",
        ...
        agent_port: 4040,
        grpc_port: 9040
      ]
    ]

  config :my_app, Core.PromExOps,
    ...
    grafana: [
      host: "http://localhost:3000",
      ...
      folder_name: "myapp-ops"
    ],
    grafana_agent: [
      working_directory: Path.expand(".grafana_ops"),
      config_opts: [
        metrics_server_path: "/metrics/ops",
        ...
        instance: "dev-ops",
        prometheus_url: "http://prometheus-ops:9090/api/v1/write",
        ...
        agent_port: 4141,
        grpc_port: 9041
      ]
    ]

Additional details and screenshots

Checklist

  • [x] I have added unit tests to cover my changes.
  • [x] I have added documentation to cover my changes.
  • [x] My changes have passed unit tests and have been tested E2E in an example project.

patmaddox avatar Aug 03 '22 18:08 patmaddox

@akoutmos seeking initial feedback

Do you think it would be useful to add a How-To about running multiple agents? Wasn't quite ready to check the "I have added documentation box" after only documenting the new grpc_port config.

What do you think of adding a -m ModuleName to the generator, so we can do e.g. mix prom_ex.gen.config --datasource myapp-ops -m PromExOps? Right now the generated module is named PromEx and would need to be updated.

patmaddox avatar Aug 03 '22 18:08 patmaddox

Just looked through the code. It looks good to me. While I don't think it is a very common use case to run multiple agents...some documentation would definitely be good. Emphasis on not double-using ports would also be nice :D.

I am also ok with adding the -m flag so long as PromEx is the default when it is not provided.

akoutmos avatar Aug 04 '22 17:08 akoutmos

@akoutmos done!

patmaddox avatar Aug 04 '22 18:08 patmaddox

Coverage Status

Coverage increased (+0.04%) to 79.258% when pulling dd0b996effa78d287cf4b8863bc91a1fa1a71dea on patmaddox:multi-agent into 611912ce63d4122fedfe8b616ed83cb88521f90f on akoutmos:master.

coveralls avatar Aug 11 '22 05:08 coveralls