Is there any Cloud API can get metrics data from a specifed Node directly not via Agent API

For example
I have a NetData cloud server
under this server , there are there nodes in my room
Now I want to get my node’s metrics data , for example CPU data of the node 1
I need to call could API to get data directly not calling NetData Agent REST API

Hello @michael_yue :wave: ,

Thanks for reaching out.

Yes there is an API you can use, will try to provide some quick guide below on how to authenticate and build your /data requests targeting a node.

Authentication

You will first need to issue a Bearer token that will be placed in the value of your HTTP request’s Authorization header like this:

Authorization: Bearer <your_bearer_token>

To create such a token on behalf of your Netdata Cloud account you will need to go to:

  1. Your Account Settings (by clicking on your account thumbnail on the bottom left)
  2. Then click on Settings
  3. Then click on API tokens on the right-hand side drawer
  4. Click the :heavy_plus_sign: icon to create a new Token, select scope:all and a enter a description of your choice.



The HTTP request

With the following POST HTTP request you may request for data from a node (or a set of nodes) within a space and that your account has access to.

curl -v 'https://app.netdata.cloud/api/v3/spaces/{space_id}/rooms/{room_id}/data' \
  -H 'Authorization: Bearer <your_bearer_token_goes_here>' \
  -H 'Content-Type: application/json \
  --data-raw '<request_payload_goes_here'
  • space_id : You may find that at your space settings (click on the :gear: at the lower left corner and you may find it at the section Info
  • room_id : It’s a bit trickier to find this one. The quickest way is to click on your Metrics tab and the open the network tab on your browser. Then check the /data calls that are being fired to populate your charts. You could quickly extract your room_id (and your space_id as well) from there. Both space_id and room_id are UUIDs.
  • JSON request payload:
{
  "format": "json2",
  "options": [
    "jsonwrap",
    "nonzero",
    "flip",
    "ms",
    "jw-anomaly-rates",
    "minify"
  ],
  "scope": {
    "contexts": [
      "system.cpu"  <--- you can change this to target any other context you need
    ],
    "nodes": [
      "xxxxxxxxx" <--- here you may add your <node_id>
    ]
  },
  "selectors": {
    "contexts": [
      "*"
    ],
    "nodes": [
      "*"
    ],
    "instances": [
      "*"
    ],
    "dimensions": [
      "*"
    ],
    "labels": [
      "*"
    ]
  },
  "aggregations": {
    "metrics": [
      {
        "group_by": [
          "dimension"
        ],
        "group_by_label": [],
        "aggregation": "avg"
      }
    ],
    "time": {
      "time_group": "average",
      "time_resampling": 0
    }
  },
  "window": {
    "after": 1734340051,
    "before": 1734340951,
    "points": 461
  }
}

Regarding the window field this would be where you define the target time window for your data request.
You could either pass in the after (>=) or before (<=) fields unix timestamps in sec.

You could also pass relative durations in sec. in there for example if you want to retrieve the last 15mins of a metric you can only pass the before field with a value of -900.

To retrieve the node_id (a UUID) you actually want to target you can navigate to he Nodes tab in your Netdata Cloud space, click on the node you are interested in and then you can extract it from the URL bar of your browser as follows:

https://app.netdata.cloud/spaces/{your-space-slug}/rooms/{your-room-slug}/nodes/{here-is-your-node_id} ...

You should check the Netdata Agent Swagger Documentation for the v2 Data Query to find more info about the rest of the fields in the payload.

Note that this is not official Netdata Cloud API documentation, it is for the Netdata Agent. But many concepts and payloads are applicable in both platforms and data queries are one of them.


We plan at some point to make things more straightforward concerning Netdata Cloud API usage and have proper docs on this but hopefully for now this will cover your needs.

Happy Monitoring!
Costas