stephenyeargin / hubot-grafana

📈🤖 Query Grafana dashboards
http://docs.grafana.org/tutorials/hubot_howto/
MIT License
154 stars 48 forks source link

graf db nginx-lua Why is the grafana homepage returned? #128

Closed fsckzy closed 4 years ago

fsckzy commented 4 years ago
grafana 6

image

stephenyeargin commented 4 years ago

That's a good question! I would have expected that command to error out instead. Where you have Nginx HTTP Connections would normally be a panel number, e.g. 4.

User> hubot graf db nginx-lua:4

It's a bit annoying that you have to guess what the Panel ID is for the graph you want on a larger Dashboard, but the parser currently doesn't know how to de-reference the panel you want from a name. I'm guessing the image rendering endpoint couldn't find what it wanted, so it defaulted to returning an image of the home page for the Grafana instance.

stephenyeargin commented 4 years ago

Reference for getting panels: https://github.com/stephenyeargin/hubot-grafana#retrieve-specific-panels

fsckzy commented 4 years ago

That's a good question! I would have expected that command to error out instead. Where you have Nginx HTTP Connections would normally be a panel number, e.g. 4.

User> hubot graf db nginx-lua:4

It's a bit annoying that you have to guess what the Panel ID is for the graph you want on a larger Dashboard, but the parser currently doesn't know how to de-reference the panel you want from a name. I'm guessing the image rendering endpoint couldn't find what it wanted, so it defaulted to returning an image of the home page for the Grafana instance.

First of all, thank you very much for your answers. I tried the following commands again, all returned to the grafana homepage

hubot graf db nginx-lua: Nginx Lua  panel-1
graf db nginx-lua:1
graf db nginx-lua: Nginx Lua
graf db nginx-lua: Nginx Lua  panel-1
.....

image image

Is there any way? What information do I need to provide?

stephenyeargin commented 4 years ago

So of the commands you provided, this is the only one I'd expect to work:

graf db nginx-lua:1

The slug for the dashboard nginx-lua is the only part needed (the "Nginx Lua" is a descriptive name, but the API doesn't understand those). The panel ID 1 is only needed if you don't want to render the entire dashboard (e.g. if you only wanted to return one of the graphs. Posting graf db nginx-lua without the :1 should return all of the panels. I still don't know why Grafana is returning the home page, but I'd suspect it's adding extra parameters it doesn't need to.

The first error you see there might be related to this issue where you'd need to increase the concurrent rendering limit if the server can support it (may run out of CPU or memory if it's too high).

One thing to double check is to go to an individual panel, click on "Share" in the context menu and then click "Direct link rendered image. This will help diagnose if there's any trouble with the image rendering function in Grafana itself.

Screen Shot 2020-08-01 at 4 11 03 PM

Screen Shot 2020-08-01 at 4 11 10 PM

fsckzy commented 4 years ago

So of the commands you provided, this is the only one I'd expect to work:

graf db nginx-lua:1

The slug for the dashboard nginx-lua is the only part needed (the "Nginx Lua" is a descriptive name, but the API doesn't understand those). The panel ID 1 is only needed if you don't want to render the entire dashboard (e.g. if you only wanted to return one of the graphs. Posting graf db nginx-lua without the :1 should return all of the panels. I still don't know why Grafana is returning the home page, but I'd suspect it's adding extra parameters it doesn't need to.

The first error you see there might be related to this issue where you'd need to increase the concurrent rendering limit if the server can support it (may run out of CPU or memory if it's too high).

One thing to double check is to go to an individual panel, click on "Share" in the context menu and then click "Direct link rendered image. This will help diagnose if there's any trouble with the image rendering function in Grafana itself.

Screen Shot 2020-08-01 at 4 11 03 PM

Screen Shot 2020-08-01 at 4 11 10 PM

image

fsckzy commented 4 years ago

I want to try again. This is the debug log.

  'nginx-lua:1',
  undefined,
  index: 0,
  input: 'yangroupaomo graf db nginx-lua:1',
  groups: undefined ]
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG nginx-lua
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG { from: 'now-6h', to: 'now' }
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG 
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG []
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG 1
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG false
[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG false

[Mon Aug 03 2020 09:37:16 GMT+0800 (China Standard Time)] DEBUG { aliasColors:
   { reading: 'semi-dark-red',
     waiting: 'semi-dark-green',
     writing: 'semi-dark-orange' },
  bars: false,
  dashLength: 10,
  dashes: false,
  fill: 1,
  gridPos: { h: 8, w: 12, x: 0, y: 0 },
  id: 6,
  legend:
   { alignAsTable: false,
     avg: false,
     current: false,
     max: false,
     min: false,
     rightSide: false,
     show: true,
     total: false,
     values: false },
  lines: true,
  linewidth: 1,
  l
  spaceLength: 10,
  stack: false,
  steppedLine: false,
  targets:
   [ { expr:
        'histogram_quantile(0.5, rate(nginx_http_request_duration_seconds_bucket{instance="$server", host="$host"}[1m]))',
       format: 'time_series',
       intervalFactor: 1,
       legendFormat: '50th percentile',
       refId: 'D' },
     { expr:
        'histogram_quantile(0.75, rate(nginx_http_request_duration_seconds_bucket{instance="$server", host="$host"}[1m]))',
       format: 'time_series',
       hide: false,
       intervalFactor: 1,
       legendFormat: '75th percentile',
       refId: 'A' },
     { expr:
        'histogram_quantile(0.95, rate(nginx_http_request_duration_seconds_bucket{instance="$server", host="$host"}[1m]))',
       format: 'time_series',
       hide: false,
       intervalFactor: 1,

  timeFrom: null,
  timeRegions: [],
  timeShift: null,
  title: 'Requests by Status - $host',
  tooltip: { shared: true, sort: 0, value_type: 'individual' },
  type: 'graph',
  xaxis:
   { buckets: null, mode: 'time', name: null, show: true, values: [] },
  yaxes:
   [ { format: 'short',
       label: null,
       logBase: 1,
       max: null,
       min: null,
       show: true },
     { format: 'short',
       label: null,
       logBase: 1,
       max: null,
       min: null,
       show: true } ],
  yaxis: { align: false, alignLevel: null } }
[Mon Aug 03 2020 09:37:19 GMT+0800 (China Standard Time)] DEBUG Uploading file: 16788 bytes, content-type[image/png]
[Mon Aug 03 2020 09:37:22 GMT+0800 (China Standard Time)] DEBUG Received file_shared message from: undefined, file_id: F0183R53213
[Mon Aug 03 2020 09:37:22 GMT+0800 (China Standard Time)] DEBUG No listeners executed; falling back to catch-all
stephenyeargin commented 4 years ago

I don't see anything obvious from the debug log. Is there not a "Direct link rendered image" button on the "Share" panel? If that button isn't there, it might indicate your Grafana server hasn't been configured for rendering the PNG images necessary for this Hubot package to work.

There is some documentation on things to check to ensure your instance meets the requirements.

fsckzy commented 4 years ago

I gave up, thanks