Last active
February 6, 2024 14:20
-
-
Save kylebrandt/d38f71326a381539c898cf9421994eae to your computer and use it in GitHub Desktop.
peakq http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Render a Basic template with POST | |
POST http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/render?var-metricName=up | |
Content-Type: application/json | |
Accept: application/json | |
{ | |
"title": "Test", | |
"vars": [ | |
{ | |
"key": "metricName", | |
"defaultValue": [ | |
"down" | |
], | |
"valueListDefinition": null | |
} | |
], | |
"targets": [ | |
{ | |
"variables": { | |
"metricName": [ | |
{ | |
"path": "$.expr", | |
"position": { | |
"start": 0, | |
"end": 10 | |
} | |
}, | |
{ | |
"path": "$.expr", | |
"position": { | |
"start": 13, | |
"end": 23 | |
} | |
} | |
] | |
}, | |
"properties": { | |
"datasource": { | |
"type": "prometheus", | |
"uid": "foo" | |
}, | |
"editorMode": "builder", | |
"exemplar": false, | |
"expr": "metricName + metricName + 42", | |
"instant": true, | |
"range": false, | |
"refId": "A" | |
} | |
} | |
] | |
} | |
### Create a basic Template (stored) (note the returned "name" property) | |
### for future requests (e.g. something like metadata.name = "ATestqkghh" | |
# @name createRequest | |
POST http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/namespaces/default/querytemplates | |
Content-Type: application/json | |
Accept: application/json | |
{ | |
"apiVersion": "peakq.grafana.app/v0alpha1", | |
"kind": "QueryTemplate", | |
"metadata": { | |
"generateName": "ATest" | |
}, | |
"spec": { | |
"title": "Test", | |
"vars": [ | |
{ | |
"key": "metricName", | |
"defaultValue": [ | |
"down" | |
], | |
"valueListDefinition": null | |
} | |
], | |
"targets": [ | |
{ | |
"variables": { | |
"metricName": [ | |
{ | |
"path": "$.expr", | |
"position": { | |
"start": 0, | |
"end": 10 | |
} | |
}, | |
{ | |
"path": "$.expr", | |
"position": { | |
"start": 13, | |
"end": 23 | |
} | |
} | |
] | |
}, | |
"properties": { | |
"datasource": { | |
"type": "prometheus", | |
"uid": "foo" | |
}, | |
"editorMode": "builder", | |
"exemplar": false, | |
"expr": "metricName + metricName + 42", | |
"instant": true, | |
"range": false, | |
"refId": "A" | |
} | |
} | |
] | |
} | |
} | |
### | |
#Set name based on the response from create | |
@name = {{createRequest.response.body.metadata.name}} | |
### Get the template created above | |
GET http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/namespaces/default/querytemplates/{{name}} | |
Content-Type: application/json | |
Accept: application/json | |
### Render the query created above (from storage) | |
GET http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/namespaces/default/querytemplates/{{name}}/render?var-metricName=up | |
Content-Type: application/json | |
Accept: application/json | |
### Delete Specific Tempalte | |
DELETE http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/namespaces/default/querytemplates/{{name}} | |
Content-Type: application/json | |
Accept: application/json | |
### Delete ALL query templates | |
DELETE http://admin:admin@localhost:3000/apis/peakq.grafana.app/v0alpha1/namespaces/default/querytemplates | |
Content-Type: */* | |
Accept: application/json | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment