I needed help making a Graph panel work using grafonnet. The generated json when imported, creates the dashboard, adds the panel but is unable to fetch any data. However, when I add a query manually on the same panel and use the same argument, it works fine. Can anyone please point out what am I missing? Am using elasticsearch as my datasource, already configured. Grafana v6.5.2, installed grafonnet via homebrew.
local grafana = import 'grafana.libsonnet';
local dashboard = grafana.dashboard;
local elasticsearch = grafana.elasticsearch;
local template = grafana.template;
local graphPanel = grafana.graphPanel;
local jiraTickets =
graphPanel.new(
'P0/P1',
span=6,
min_span=6,
format='short',
fill=0,
min=0,
decimals=2,
datasource='abc',
legend_values=true,
legend_min=true,
legend_max=true,
legend_current=true,
legend_total=false,
legend_avg=true,
legend_alignAsTable=true,
)
.addTarget(
elasticsearch.target(
'<my_query>',
'@timestamp',
id=1,
metrics=[{
id:2,
type: 'count',
}],
alias='P0/P1 Count',
bucketAggs=[{
field: "timestamp",
id:3,
settings: {
interval: "auto",
min_doc_count: 0,
trimEdges: 0
},
type: "date_histogram"
}],
)
);
dashboard.new(
'Generated Jira P0/P1',
editable=true,
schemaVersion=18,
time_from='now-30d',
tags=['generated'],
)
.addPanels(
[
jiraTickets { gridPos: { h: 9, w: 15, x: 0, y: 0 } },
]
)
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 44,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": “abc",
"decimals": 2,
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 15,
"x": 0,
"y": 0
},
"hiddenSeries": false,
"id": 2,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"minSpan": 6,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": null,
"seriesOverrides": [],
"spaceLength": 10,
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "P0/P1 Count",
"bucketAggs": [
{
"field": "timestamp",
"id": 3,
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"id": 1,
"metrics": [
{
"field": "select field",
"id": 2,
"type": "count"
}
],
"query": "<my_query>",
"refId": "A",
"timeField": "timestamp"
},
{
"alias": "Manual",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"metrics": [
{
"field": "select field",
"id": "1",
"type": "count"
}
],
"query": "<my_query>",
"refId": "B",
"timeField": "timestamp"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "P0/P1",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": 2,
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": 0,
"show": true
},
{
"decimals": 2,
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": 0,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"refresh": "5s",
"schemaVersion": 21,
"style": "dark",
"tags": [
"generated"
],
"templating": {
"list": []
},
"time": {
"from": "now-30d",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "browser",
"title": "Generated Jira P0/P18",
"uid": "7AIqH6yZz",
"version": 1
}
No errors on the UI, any pointers would be greatly appreciated.