Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds proposal for Prometheus metrics #48

Merged
merged 15 commits into from
Feb 2, 2021
Merged

Adds proposal for Prometheus metrics #48

merged 15 commits into from
Feb 2, 2021

Conversation

aspic
Copy link
Collaborator

@aspic aspic commented Jan 21, 2021

As mentioned in #46, adds initial support of Prometheus metrics. These metrics must then either be pushed, or as in this case be scraped from the endpoint /prometheus. This PR is merely to show what is possible, and only exposes a few of the metrics.

One must-fix if we decide to progress with this is to ensure /prometheus endpoint is "protected" somehow (at least if exposing anything like IP adresses).

A method of testing this can be to add this to the docker-compose-file (the proxy exposes metrics → prometheus scrapes metrics → grafana displays metrics):

nanorpcproxy:
....docker-compose-things

prometheus:
  image: prom/prometheus
  volumes:
    - /path/to/prometheus.yml:/etc/prometheus/prometheus.yml
  ports:
    - 9090:9090

grafana:
  image: grafana/grafana
  depends_on:
    - prometheus
  ports:
    - 3000:3000
  user: "472"

And make the prometheus.yml point to the Nano RPC proxy prometheus endpoint like this:

global:
  scrape_interval: 30s
  scrape_timeout: 10s
  
scrape_configs:
  - job_name: services
    metrics_path: /prometheus
    static_configs:
      - targets:
          - 'nanorpcproxy:9950'

When setting up Prometheus as datasource in Grafana, you would then get live metrics like this:

Screenshot_2021-01-21_19-57-30

@aspic aspic added the enhancement New feature or request label Jan 21, 2021
@aspic aspic requested a review from Joohansson January 21, 2021 19:47
@aspic aspic linked an issue Jan 21, 2021 that may be closed by this pull request
@Joohansson
Copy link
Owner

Sounds interesting! I guess you also have to add the extra setting to settings.json.default?
Did you leave that out by purpose?

@Joohansson Joohansson marked this pull request as draft January 23, 2021 16:39
@aspic
Copy link
Collaborator Author

aspic commented Jan 24, 2021

Updated PR with these changes:

  • Skips rate limiting of the /prometheus endpoint
  • Prometheus is only enabled if the enable_prometheus_for_ips is set to avoid someone exposing the endpoint to the whole world. This address should then preferable only be on the internal network.
  • Adds metrics for more stuff (rate limited, and external calls)

@aspic aspic marked this pull request as ready for review January 24, 2021 19:34
@Joohansson Joohansson merged commit 744ba12 into master Feb 2, 2021
@Joohansson Joohansson deleted the prometheus-rfc branch February 2, 2021 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Research Prometheus metrics
2 participants