→ Applies to: SynetoOS 5.x

 

Create the token for the monitoring API


Step 1. Login to SynetoOS GUI


Step 2. Click on the question mark in the top right-hand corner


 

Step 3. Click on View API explorer


You'll be redirected to Syneto Doorman API

 

Step 4. Click on POST /api-keys


 

Step 5. Click on Try it out


 

Step 6. Prepare this code with the information needed (replace <name><user><resource><network/subnet><validity> with the correct information)

{
  "name": "<name>",
  "owner": "<user>",
  "scopes": [
    {
      "resource": "/<resource>",
      "permissions": [ "GET" ]
    }
  ],
  "allowed_networks": [ "<network/subnet>" ],
  "validity": "<validity>"
}

name: an arbitrary name representing the app that uses the API key. For monitoring purposes, the name could be “monitoring”;

owner: any name;

resource: specifies the API endpoint for which the key is intended. For monitoring purposes, the resource is named “prometheus”;

permissions: defines the allowed methods (GET, POST, DELETE). For monitoring purposes, the correct value is “GET”;

allowed_network: indicates the networks from which the connection is allowed, with the format “0.0.0.0/0”;

validity: specifies the number of days the key will remain valid, suffixed with “d”. For example “365d” (for one year).


For monitoring, the resource is /prometheus.

 

Step 7. Empty the “Request body” field and paste the code from Step 6


 

Step 8. Click on Execute


 

Step 9. The system responds with a Code 200 and a token will be provided


Save the token in a safe place, since this will be the only time it will be visible.

If you lost it, you have to create a new one.

 

API Endpoint URLs

Step 1. List all available metrics (replace <syneto-os-ip> with the correct information)

https://<syneto-os-ip>/prometheus/api/v1/label/__name__/values

 

Step 2. Query a specific metric (replace <syneto-os-ip> and <metric-name> with the correct information)

https://<syneto-os-ip>/prometheus/api/v1/query?query=<metric-name>

 

Step 3. Use the following command to query a metric (replace <api_key> and <metric-name> with the correct information)

curl -k \
 -H "x-api-key: <api_key>" \
 "https://syneto/prometheus/api/v1/query?query=<metric-name>"

EXAMPLE

curl -k \
 -H "x-api-key: 5DQvxhziIbBw06cbnIFPeC8gfm3zs5Feqt8DDIVHHGE" \
 "https://syneto/prometheus/api/v1/query?query=latest_replication_status"