json_exporter icon indicating copy to clipboard operation
json_exporter copied to clipboard

JSON key with space

Open saurabhtodankar opened this issue 3 years ago • 4 comments

{ "List": "1000000013-N-DN2804-N" "BrkList": "DN2804", "No of connected clients:": "1", "No of Socket Connections:": "37", "No of Socket Connected prop true:": "5", "REMARKS": "OK" }

I want to get value of "no of connected clients" can anyone pls help me ? thanks in advance

saurabhtodankar avatar Jul 08 '21 10:07 saurabhtodankar

have a try,pls values: example: '{$["no of connected clients"]}'

qwzhou89 avatar Oct 26 '21 11:10 qwzhou89

Thanks but it didnt work for me

saurabhtodankar avatar Oct 27 '21 10:10 saurabhtodankar

Not the nicest, but this seems to work. Notice that your JSON is missing a ,, and many of the keys include :

metrics:
- name: connected_clients
  type: value
  path: "{$['No\\ of\\ connected\\ clients:']}"

fredr avatar Nov 08 '21 13:11 fredr

i had the same issue,according to #114,i config like below and it works json:

    {
        "data": {
            "FAN1": [
                {
                    "Device": "FAN",
                    "Fan": "F1",
                    "Speed (RPM)": "9398.00",
                    "Status": "OK"
                },
                {
                    "Device": "FAN",
                    "Fan": "F2",
                    "Speed (RPM)": "8953.00",
                    "Status": "OK"
                }
            ],
        },
        "executed_command": "show fan",
        "status": "OK",
        "status_message": ""
    }

config:

  metrics:
  - name: speed_rpm
    path: '{ .data.FAN1[0] }'
    type: object
    labels:
      device: '{.Device}' # static label
    values:
      speed: '{.Speed\ (RPM)}'

thewangcj avatar Dec 28 '23 07:12 thewangcj