Getting more from JSON Path from Http API

Hello,

I have two questions about this input.

Can I use variables in the url I’m calling ?

For instance :

https://${subdomainList}.example.org/api/thing

And second question, how can I manage an API authentication using this input ?

Same question with a token with a limited validity ?

Thanks ahead !

Did you read docs about REST API?
https://docs.graylog.org/en/3.3/pages/configuration/rest_api.html

No, because I’m not requesting Graylog API so I didn’t think of it
I’m going to have a look. I’m not sure to get what I want from there though.

Please describe what do you want to achieve, it’s not very clear…

Sure.

I want to know if it is feasible to get data from several Rest APIs within one JSon Path input using variables in the url called. Because I would be getting data from like 50 apis all identically formatted, including the url.

this is what I read : https://docs.graylog.org/en/3.3/pages/sending_data.html#json-path-from-http-api-input

API auth depends on auth header, add one of it to Input field: Additional HTTP headers

You could try:

  1. Authorization: Basic Zm9vOmJhcg==
  2. Authorization: Bearer ACCESS_TOKEN

Or another depends on application

Thanks for your answer.
I my specific case, it won’t work, because the token has an expiration :frowning:
But I learnt something thanks to you.

Why not use REST API to change token on expiration updating Input’s header field?

  1. Get all Inputs:
    GET /api/system/inputs
    curl -u user_token:token -H 'Content-Type: application/json' -H 'X-Requested-By: cli' 'http://graylog.domain.com:9000/api/system/inputs'

  2. Get json Input parameters:
    GET /api/system/inputs/INPUT_ID
    curl -u user_token:token -H 'Content-Type: application/json' -H 'X-Requested-By: cli' 'http://graylog.domain.com:9000/api/system/inputs'

  3. Update token parameters (for example field headers)
    PUT /api/system/inputs/INPUT_ID
    curl -i -X POST -u user_token:token -H 'Content-Type: application/json' -H 'X-Requested-By: cli' 'http://graylog.domain.com:9000/api/system/inputs/INPUT_ID' -d @update-headers.json

update-headers.json file should contains original Input parameters with updated field headers:

Requered parameters:

{
  "title": "string",
  "type": "string",
  "global": "boolean",
  "configuration": "object",
  "node": "string"
}

So my example file update-headers.json:

{
  "title": "Json test2",
  "global": false,
  "type": "org.graylog2.inputs.misc.jsonpath.JsonPathInput",
  "configuration": {
    "headers": "Authentication: token",
    "path": "$.store.book[1].number_of_orders",
    "throttling_allowed": false,
    "target_url": "http://example.org/api",
    "interval": 1,
    "override_source": null,
    "source": "yourapi",
    "timeunit": "MINUTES"
  },
  "node": "6279b6d3-bfc3-4394-9340-90f47c91b816"
}

Thanks for your very interesting answer.
It looks like you’re requesting Graylog API when I am not. I will be requesting another rest API from a different solution.

Nonetheless, I think I can find some inspiration in your message.
Maybe this JSON input is dedicated to request Graylog and nothing else ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.