Menu
hosted-metrics-api Quick Start

Quick Start

First setup HM-API as described in the manual installation or the helm installation docs

Using the API

List plans

curl -uapiuser:apipass  https://api.tsdb.yourcompany.com/plans

To modify plans, just edit the hm-api-config configmap

kubectl edit configmap hm-api-config

Create an instance

curl -uapiuser:apipass  https://api.tsdb.yourcompany.com/instance -H "content-type: json" -d'{"plan": {"Name": "small", "ScaleFactor": 1}, "org": 1, "name": "demo"}'

Fields:

  • plan.Name should match the name of a plan defined on the platform.
  • plan.ScaleFactor sets the multiplication factor for CPU and Memory limits defined in the plan.
  • org should be a positive integer value to represent a company or organisation
  • name is the unique name of the deployment such as “prod” or “demo”.

The org and name combination should be unique.

Get instance config

curl -uapiuser:apipass  https://api.tsdb.yourcompany.com/instance/<org>/<name>

Update an instance

first get the instance config, then modify it and post it back. Replace <org> and <name> with desired values.

curl -uapiuser:apipass  https://api.tsdb.yourcompany.com/instance/<org>/<name> |json_pp > /tmp/<org>-<name>.json
# edit /tmp/<org>-<name>.json
curl -uapiuser:apipass  https://api.tsdb.yourcompany.com/instance -H "content-type: json" -d@/tmp/<org>-<name>.json

These are the most interesting fields:

  • Color: Hosted-metrics-api supports blue-green-deployment for the read cluster (Metrictank read instances and Graphite) This should be a or b to denote the active color. (a by default)
  • Overrides: Here you can put any environment variables to be applied on the Metrictank, Graphite, etc pods, to override what was set in the hm-api-config configmap.
  • OverridesA: Overrides that will apply to the Graphite/Metrictank a color
  • OverridesB: Overrides that will apply to the Graphite/Metrictank b color
  • Plan: To finetune cpu requests/limits, the number of partitions and scaleFactor (see above)
  • Storage: Here you can set custom storage-schemas.conf and storage-aggregation.conf

List All Jobs

GET https://api.tsdb.yourcompany.com/jobs/<org>/

Get a Job

GET https://api.tsdb.yourcompany.com/jobs/<org>/<jobid>

Delete a Job

DELETE https://api.tsdb.yourcompany.com/jobs/<org>/<jobid>

Create Importer

POST https://api.tsdb.yourcompany.com/instance/<org>/<name>/importer
Body
{
  "key": "<api_password>"
}

Delete Importer

DELETE https://api.tsdb.yourcompany.com/instance/<org>/<name>/importer