json_exporter icon indicating copy to clipboard operation
json_exporter copied to clipboard

convert string format to timestamp

Open turalmirza opened this issue 1 year ago • 1 comments

{ "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

turalmirza avatar Jul 04 '24 09:07 turalmirza

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).

shadowpanther avatar Jan 22 '25 19:01 shadowpanther