openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
168 stars 54 forks source link

My Prometheus is unable to scrape any telemetry data from gNMIc although gNMIc is collecting data from the target and exposing it on port 9273. #399

Closed arbabali999 closed 5 months ago

arbabali999 commented 5 months ago

PFB prometheus.yml and gnmic.yml. My Prometheus is unable to scrape any telemetry data from gnmic although gnmic is collecting data from the target and exposing it on port 9273.

prometheus.yml:

scrape_configs:

gnmic.yml:

port: 57400 timeout: 10s insecure: true

targets: 192.168.69.38: username: admin password: admin123 subscriptions:

subscriptions: sros_cpu: paths:

outputs: prom: type: prometheus listen: :9273 path: /metrics metric-prefix: gnmic append-subscription-name: true export-timestamps: true debug: false event-processors:

processors: GNU nano 6.2
trim-prefixes: event-strings: value-names:

I have verified using below command (providing one as reference) about subscription path provided in gnmic.yml that subscriptions are correct.

sudo gnmic -a 192.168.69.38:57400 --insecure -u admin -p admin123 -d sub --path /state/system/cpu[sample-period=60]/summary/usage

Manual Output:

"source": "192.168.69.38:57400", "subscription-name": "default-1710885725", "timestamp": 1017826625194935505, "time": "2002-04-03T14:37:05.194935505+05:00", "prefix": "state/system/cpu[sample-period=60]/summary/usage", "updates": [ { "Path": "cpu-time", "values": { "cpu-time": 47593972 } }, { "Path": "time-used", "values": { "time-used": "47593972" } }, { "Path": "cpu-usage", "values": { "cpu-usage": "4.97" } } ] }

Same can be verified using, sudo journalctl -u gnmic.service -f as it is showing the results on real time.

Also, i don't get anything when using below command.

curl http://localhost:9273/metrics

karimra commented 5 months ago
"timestamp": 1017826625194935505,
"time": "2002-04-03T14:37:05.194935505+05:00",

Your device is reporting old timestamps (probably not synced to NTP). Metrics expire if their timestamp is older that 60s. Either fix the timestamps reported by the device or set expiration: -1 under the prometheus output to avoid metrics being deleted. The second solution means that metrics will never go stale and expire which might not be what you want.

arbabali999 commented 5 months ago

It's my testing router so i performed second solution. So, i have started to see the information using curl http://localhost:9273/metrics but Prometheus is still unable to reflect anything using expression bar. Can you please assist.

gnmic-scrap-log.txt

arbabali999 commented 5 months ago

Thanks alot. Issue resolved. expiration: -1 only started showing metrics in the browser. Eventually i had to sync the time of both Router and gNMIc. Prometheus then started scrapping metrics.

karimra commented 5 months ago

Good to hear. You probably have export-timestamps: true, in that case gNMIc exports the timestamp of the metric to Prometheus. That timestamp being too far in the past, is dropped by Prometheus. If you change export-timestmaps to false, the first solution would have been enough.