prometheus-community / json_exporter

A prometheus exporter which scrapes remote JSON by JSONPath
Apache License 2.0
632 stars 195 forks source link

JSONPath problem - maybe... #285

Open mikkop71 opened 8 months ago

mikkop71 commented 8 months ago

Hello,

Site I am trying to read returns following json data:

{
  "hrmWebFrontStatus": {
    "isAnonymousUser": true,
    "hrmWebFrontVersion": "1.6.2311.2797",
    "hrmWebFrontType": "YKS",
    "maxRequestSize": "~ 20 MiB"
  },
  "hrmBackendStatus": {
    "hrmBackendStatusOk": true,
    "hrmBackendHttpOk": true,
    "hrmBackendType": "YKS",
    "hrmBackendVersion": "1.6.2311.2797",
    "hrmBackendVersionOk": true,
    "hrmBackendDatabaseOk": true,
    "hrmBackendDatabaseVersion": 6830,
    "hrmBackendDatabaseNewestScriptVersion": 6830,
    "hrmBackendDatabaseVersionOk": true,
    "maxRequestSize": "> 30 MiB",
    "hrmBackendMalwareScanOk": true
  },
  "authStatus": {
    "authBothOk": false,
    "authHttpOk": false,
    "exception": true
  }
}

My json_exporter config is following:

modules:
  default:
    headers:
      MyHeader: MyHeaderValue
    metrics:
      - name: webfrontstatus
        type: object
        help: General statistics of the webfrontstatus
        path: '{.hrmWebFrontStatus}'
        values:
          isAnonymousUser: '{.isAnonymousUser}'
          hrmWebFrontVersion: '{.hrmWebFrontVersion}'
      - name: webbackstatus
        type: object
        help: General statistics of the webbackstatus
        path: '{.hrmBackendStatus}'
        values:
          hrmBackendStatusOk: '{.hrmBackendStatusOk}'
          hrmBackendHttpOk: '{.hrmBackendHttpOk}'
          hrmBackendVersion: '{.hrmBackendVersion}'
          hrmBackendVersionOk: '{.hrmBackendVersionOk}'
          hrmBackendDatabaseOk: '{.hrmBackendDatabaseOk}'
          hrmBackendDatabaseVersion: '{.hrmBackendDatabaseVersion}'
          hrmBackendDatabaseVersionOk: '{.hrmBackendDatabaseVersionOk}'

When I try to following command: curl http://localhost:7979/probe?target=https://xxxweb.xxx.xx/home/status?format=json nothing seems to happen, no error messages just nothing.

Is there something wrong with the config or how I could debug situtation?

rustycl0ck commented 8 months ago

Your query string is not URL-encoded, which might be causing this. There shouldn't be 2 ? in the url. Maybe try replacing the second ? with %3F to see if that works.

mikkop71 commented 8 months ago

Actually prometheus target formats to this url if I click the link there, but it doesn't seem to work either: http://localhost:7979/probe?target=https%3A%2F%2Fxxxweb.xxx.xx%2Fhome%2Fstatus%3Fformat%3Djson