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

Cannot read property 'result' of undefined in Grafana #30

Closed
imMatt opened this issue Feb 23, 2018 · 2 comments
Closed

Cannot read property 'result' of undefined in Grafana #30

imMatt opened this issue Feb 23, 2018 · 2 comments
Assignees
Labels

Comments

@imMatt
Copy link

imMatt commented Feb 23, 2018

Hello,

Currently trying to hook up Swagger-Stats with Grafana to handle remote monitoring and alerts.
I've connected Grafana to /swagger-stats/metrics and am getting a successful response.

Despite this I'm getting 'Cannot read property 'result' of undefined'.
Upon digging I've found that there is not diffrent between the response of /swagger-stats/metrics
and /swagger-stats/metrics/api/v1/query_range?query=api_all_request_total&start=1519362432&end=1519363332&step=30

Is this responsible for the issue? and is there any way around this.

Swagger-Stats & NodeJS at latest versions. Running behind Nginx reverse proxy.

Response for /swagger-stats/metrics/api/v1/query_range?query=api_all_request_total&start=1519362432&end=1519363332&step=30
queryresp.txt

@sv2
Copy link
Collaborator

sv2 commented Feb 23, 2018

Hi @imMatt, looks like you are missing one step ... Grafana should not be querying /swagger-stats/metrics endpoint directly. This endpoint returns Prometheus metrics; you need to install Prometheus and configure it to scrape metrics from /swagger-stats/metrics endpoint. Prometheus will store collected metrics in it's database. Then you configure Grafana to get data from Prometheus - query that you mentioned (api/v1/query_range?query=api_all_request_total&start=1519362432&end=1519363332&step=30) is Prometheus API (https://prometheus.io/docs/prometheus/latest/querying/api/)
Here is example scrape configuration for Prometheus to get metrics from /swagger-stats/metrics:

scrape_configs:
  - job_name: 'sws-spectest'
    scrape_interval: '10s'
    metrics_path: '/swagger-stats/metrics'
    static_configs:
      - targets: ['localhost:3040']

Here is an illustration of how it should be set up:
image

@sv2 sv2 self-assigned this Feb 23, 2018
@sv2 sv2 added the question label Feb 23, 2018
@imMatt
Copy link
Author

imMatt commented Feb 27, 2018

Oh, my bad. Thank-you very much will have a look into that later today!

Thanks again,
Matt

@sv2 sv2 closed this as completed Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants