json_exporter
json_exporter copied to clipboard
convert string format to timestamp
{ "id": 329, "username": "demo", "last_activity_on": "2024-06-29" } hi , I have a json output like this.i use last_activity as label in my metrics. but in promtheus side when i want to list last_activiy users more than 30 day promtheus cant understant it. beacuse date format writing in label as a string format. how can i solve this problem? here is my config file
modules:
gitlab:
metrics:
- name: user_info
type: object
help: "User ID fetched from JSON"
path: '{ [*] }'
labels:
username: '{.name}'
last_activity: '{.last_activity_on}'
values:
user_id: '{.id}'
http_client_config:
tls_config:
insecure_skip_verify: true
Have a similar use-case. In the JSON I need to parse, the values are grouped like this:
"pm1": {
"value": 75.333,
"time": "2025-01-22T19:30:19Z",
"unit": "ug/m3"
},
The value is already timestamped here, but it is in the ISO 8601 format, and I'd like to get this timestamp into Prometheus (e.g., convert it into epoch and put in into the epochTimestamp).