Skip to content

Instantly share code, notes, and snippets.

@app.route('/')
def health_check():
return 'This datasource is healthy.'
@app.route('/search', methods=['POST'])
def search():
return jsonify(['my_series', 'another_series'])
@Jonnymcc
Jonnymcc / index.py
Created October 8, 2018 22:17
Grafana simplejson datasource query endpoint
@app.route('/query', methods=['POST'])
def query():
req = request.get_json()
data = [
{
"target": req['targets'][0]['target'],
"datapoints": [
[861, convert_to_time_ms(req['range']['from'])],
[767, convert_to_time_ms(req['range']['to'])]
]
@Jonnymcc
Jonnymcc / index.py
Created October 8, 2018 22:21
Grafana simplejson datasource annotations endpoint
@app.route('/annotations', methods=['POST'])
def annotations():
req = request.get_json()
data = [
{
"annotation": 'This is the annotation',
"time": (convert_to_time_ms(req['range']['from']) +
convert_to_time_ms(req['range']['to'])) / 2,
"title": 'Deployment notes',
"tags": ['tag1', 'tag2'],
@Jonnymcc
Jonnymcc / index.py
Created October 8, 2018 22:26
Grafana simplejson datasource tag-keys endpoint
@app.route('/tag-keys', methods=['POST'])
def tag_keys():
data = [
{"type": "string", "text": "City"},
{"type": "string", "text": "Country"}
]
return jsonify(data)
@Jonnymcc
Jonnymcc / index.py
Created October 8, 2018 22:28
Grafana simplejson datasource tag-values endpoint
@app.route('/tag-values', methods=['POST'])
def tag_values():
req = request.get_json()
if req['key'] == 'City':
return jsonify([
{'text': 'Tokyo'},
{'text': 'São Paulo'},
{'text': 'Jakarta'}
])
elif req['key'] == 'Country':
@Jonnymcc
Jonnymcc / gist:3fe98653abfc8a44abf2fc64528b092d
Created October 22, 2019 14:40
github provider debug output
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: ---[ RESPONSE ]--------------------------------------
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: HTTP/1.1 304 Not Modified
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: Access-Control-Allow-Origin: *
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: Cache-Control: private, max-age=60, s-maxage=60
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: Content-Security-Policy: default-src 'none'
2019-10-22T14:06:59.385Z [DEBUG] plugin.terraform-provider-github_v2.2.1_x4: Date: Tue, 22 Oct 2019 14:06:59 GMT
2019-10-22T14:06:59.385Z [D