sysulq / nginx-vts-exporter

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption
https://sysulq.github.io/nginx-vts-exporter/
MIT License
645 stars 142 forks source link

Error "expected a valid start token" in Prometheus target #105

Closed sonnh-uit closed 1 year ago

sonnh-uit commented 1 year ago

Hi all,

I am using nginx-vts-exporter as exporter to Prometheus. When I add it on, the dashboard has an error named expected a valid start token, got "<" ("INVALID") while parsing: "<" (see picture). But when I use curl http://10.30.80.33/metrics on the machine which installed prometheus, it was return result. Open link in web browser have same response. image I tried change metrics_path to /metrics/format/json but it not work too. I see some people have same problem with me but not yet have answer, so I create this Issue. Here is my job config:

- job_name: 'nginx-vts'
    metrics_path: /metrics
    static_configs:
      - targets: ['10.30.80.33:80']

Here is result in browser image

And here is result when I curl from Prometheus server image

Everyone whose know, please help me fix this problem and tell me why it happen. Thanks advance.

sonnh-uit commented 1 year ago

Hello, I was fixed problem.

The root cause by config in vts module. To match type vts-exporter to prometheus, you must config output format it to prometheus. Change vhost_traffic_status_display_format html; to vhost_traffic_status_display_format prometheus; and keep metrics_path is /metrics to fix this problem.