Skip to content

KPIs usage

Santiago Rodríguez edited this page Aug 31, 2017 · 3 revisions

This page details the KPIs-related endpoints of the SONATA Gatekeeper API.

The KPIs are made to create a metrics registration associated with the relevant events that occur in the Sonata Service Platform (SP)

/kpis

PUT

Through this endpoint PUT request, the Gatekeeper accepts a SONATA KPI and stores it in the Push Gateway.

  • Request:
curl -X PUT <base URL>/kpis -H 'authorization:bearer <token>' -d '{"job":"sonata", "instance":"gtkapi", "metric_type":"counter", "name":"services_instantiation_requests_queries", "docstring":"how many service instantiation requests are there", "base_labels":{"result":"ok", "uuid":"", "elapsed_time":"0.550363579", "method":"GET", "module":"services", "time_stamp":"2017-08-30 14:54:47 UTC"}}'
  • Response:
{"status":"201", "data":{}, "message":"Metric updated"}

GET

Through this endpoint GET request, the Gatekeeper returns a JSON formatted paginated list of all the KPIs.

  • Request:
curl <base URL>/kpis -H 'authorization:bearer <token>'
  • Response:
{
	"status": 200,
	"data": [{
			"name": "http_requests_total",
			"help": "Total number of HTTP requests made.",
			"type": "COUNTER",
			"metrics": [{
					"labels": {
						"code": "200",
						"handler": "prometheus",
						"method": "get"
					},
					"value": "296"
				}, {
					"labels": {
						"code": "202",
						"handler": "push",
						"method": "post"
					},
					"value": "6"
				}, {
					"labels": {
						"code": "202",
						"handler": "push",
						"method": "put"
					},
					"value": "581"
				}, {
					"labels": {
						"code": "500",
						"handler": "prometheus",
						"method": "get"
					},
					"value": "3"
				}
			]
		}, {
			"name": "package_on_boardings",
			"help": "how many packages have been on-boarded",
			"type": "COUNTER",
			"metrics": [{
					"labels": {
						"elapsed_time": "0.920440778",
						"instance": "gtkapi",
						"job": "sonata",
						"method": "POST",
						"module": "packages",
						"result": "ok",
						"time_stamp": "2017-08-30 15:49:27 UTC",
						"uuid": "0470e2e4-7bcb-4cb1-a2a5-05f0f54e2623"
					},
					"value": "1"
				}, {
					"labels": {
						"elapsed_time": "3.11622423",
						"instance": "gtkapi",
						"job": "sonata",
						"method": "POST",
						"module": "packages",
						"result": "ok",
						"time_stamp": "2017-08-30 15:49:25 UTC",
						"uuid": "74c85a85-2583-49be-a485-fb8f8d086a68"
					},
					"value": "1"
				}
			]
		},{
			...
		}	
	]
}

/kpis?name=<kpi_name>

GET

Through this endpoint GET request, the Gatekeeper returns a JSON formatted request data.

  • Request:
curl <base URL>/kpis?name=<kpi_name> -H 'authorization:bearer <token>'
  • Response:
{
	"status": 200,
	"data": {
		"name": "http_requests_total",
		"help": "Total number of HTTP requests made.",
		"type": "COUNTER",
		"metrics": [{
				"labels": {
					"code": "200",
					"handler": "prometheus",
					"method": "get"
				},
				"value": "297"
			}, {
				"labels": {
					"code": "202",
					"handler": "push",
					"method": "post"
				},
				"value": "6"
			}, {
				"labels": {
					"code": "202",
					"handler": "push",
					"method": "put"
				},
				"value": "582"
			}, {
				"labels": {
					"code": "500",
					"handler": "prometheus",
					"method": "get"
				},
				"value": "3"
			}
		]
	}
}
Clone this wiki locally