IzakMarais / reporter

Service that generates a PDF report from a Grafana dashboard
Apache License 2.0
958 stars 308 forks source link

Stat Panel not working #222

Open fadjar340 opened 4 years ago

fadjar340 commented 4 years ago

Dear Sir,

When I use the grafana-reporter for Stat panel horizontally, the result of the PDF is not as expected. The Stat panel filled with group by for some field and also time histogram. The Stat then show all result in the horizontal orientation. The PDF result was messy and not show the value and proper panel.

image

And below the panel JSON

{
  "datasource": "Heartbeat",
  "cacheTimeout": null,
  "gridPos": {
    "h": 3,
    "w": 24,
    "x": 0,
    "y": 3
  },
  "id": 37,
  "interval": "30s",
  "links": [],
  "options": {
    "graphMode": "none",
    "colorMode": "value",
    "justifyMode": "center",
    "fieldOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "defaults": {
        "thresholds": {
          "mode": "absolute",
          "steps": [
            {
              "color": "#C4162A",
              "value": null
            },
            {
              "color": "#C4162A",
              "value": 0
            },
            {
              "color": "#299c46",
              "value": 1
            }
          ]
        },
        "mappings": [
          {
            "from": "-1",
            "id": 0,
            "text": "DOWN",
            "to": "0",
            "type": 2
          },
          {
            "from": "0",
            "id": 1,
            "text": "UP",
            "to": "1",
            "type": 2
          }
        ],
        "nullValueMode": "connected",
        "unit": "none"
      },
      "overrides": []
    },
    "orientation": "auto"
  },
  "pluginVersion": "6.7.3",
  "targets": [
    {
      "bucketAggs": [
        {
          "fake": true,
          "field": "url.domain",
          "id": "3",
          "settings": {
            "min_doc_count": 1,
            "order": "desc",
            "orderBy": "_term",
            "size": "15"
          },
          "type": "terms"
        },
        {
          "field": "@timestamp",
          "id": "2",
          "settings": {
            "interval": "auto",
            "min_doc_count": 0,
            "trimEdges": 0
          },
          "type": "date_histogram"
        }
      ],
      "metrics": [
        {
          "field": "summary.up",
          "id": "1",
          "inlineScript": null,
          "meta": {},
          "pipelineAgg": "select metric",
          "settings": {},
          "type": "avg"
        }
      ],
      "query": "monitor.type: icmp",
      "refId": "A",
      "timeField": "@timestamp"
    }
  ],
  "timeFrom": null,
  "timeShift": null,
  "title": "",
  "transparent": true,
  "type": "stat"
}

I think the latest version of Grafana and panel need some modification into this tools.

Regards, Fadjar340

IzakMarais commented 4 years ago

This is an issue with the panel author not supporting grafana's PNG rendering. So it is an interaction between the panel and grafana. You can test it via the grafana UI by using the panel->share->direct-link-rendered-image functionality. You can log a bug with the panel authors.

fadjar340 commented 4 years ago

Dear @IzakMarais ,

I've done some changes in the code to changes the IsSinglestat to IsStat and customized several files, then all the panel can rendered into PDF. Because the Grafana will use Stats as default panel for singlestat, in the near future, I think better to adapt the code to this features. I saw it the tweet from Grafana team.

Regards, Fadjar Tandabawana

IzakMarais commented 4 years ago

Hmm, maybe I misunderstood the problem. I thought it was a third party panel. Is it a built-in grafana panel giving problems? Can you reproduce the problems by using the grafana UI (no reporter in the loop) to render the panel PNG?

fadjar340 commented 4 years ago

I saw the render was successful, but the reporter can't handle the panel type...

IzakMarais commented 4 years ago

Aah so it is related to the dashboard JSON structure somehow. I see. Could you share your changes?

fadjar340 commented 4 years ago

I'll get the files for you.... Wait... in the next message

fadjar340 commented 4 years ago

This the file that I was modified...

I forgot to save the api_test.go to another file... The .ori is the original files.

Also the template, I use the modified template, just change the IsSinglestat to IsStat, the other still the same

grafana.zip

fadjar340 commented 4 years ago

Hi @IzakMarais , any update about new release?

IzakMarais commented 3 years ago

Sorry for the slow turnaround time.

Will need to schedule some work time to look at this.

Edunzz commented 2 years ago

@IzakMarais Great work @IzakMarais Please can you apply the changes propoused by @fadjar340