Giter Site home page Giter Site logo

stephenyeargin / hubot-grafana Goto Github PK

View Code? Open in Web Editor NEW
154.0 154.0 48.0 1.57 MB

๐Ÿ“ˆ๐Ÿค– Query Grafana dashboards

Home Page: http://docs.grafana.org/tutorials/hubot_howto/

License: MIT License

Shell 0.63% JavaScript 99.16% Dockerfile 0.21%
grafana graphs hacktoberfest hubot hubot-scripts s3

hubot-grafana's Introduction

header image

I am a software engineer building web applications in Ruby, PHP, and Javascript. I have also worked as an engineering manager, systems administrator, project manager, graphic designer, marketer, and journalist.

hubot-grafana's People

Contributors

acee11 avatar dependabot-preview[bot] avatar dependabot[bot] avatar gentunian avatar gkaskonas avatar keescbakker avatar klynch avatar kongo2002 avatar kstevena avatar lanyonm avatar liptanbiswas avatar mtchurch avatar neilcronin avatar pinguingman avatar potchin avatar shonenada avatar stephenyeargin avatar superbrothers avatar tenzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-grafana's Issues

Add more filters in panel title

Hello,

hubot graf db graphite-carbon-metrics:cpu - Get only the panels containing "cpu" (case insensitive) in the title
A great improvement could be to search for cpu&memory or cpu&<text>

My use case here, is that I have a row with a panel for each host. I would like to be able to display this panel but only for a host (as I don't use host var for this dashboard)

What do you think about this ?

Thanks

Templated dashboards

We have one dashboard which show general metrics for each server collected with collectd. It is set up as a templated dashboard where we pick the name of the server we want to get the metrics for. Having an ability to specify a value for a templated dashboard would allow us to use this dashboard for all servers and specify that ie. want metrics for the "nginx" server.

I assume it would have to be specified as a key=value pair, since there may be multiple values for a templated dashboard.

Pause/Unpause all alerts in one shot does not work

Describe the bug
Command graf pause all alerts and graf unpause all alerts does not work. Bot returns a permission denied error when trying in Slack. This is because the endpoint admin/pause-all-alerts is part of Grafana Admin API and it is clearly mentioned in Grafana documentation that The Admin HTTP API does not currently work with an API Token.

To Reproduce
Steps to reproduce the behavior:

  1. Data source '...'
  2. Command entered myhubot graf unpause all alerts
  3. In slack it says permission denied. In Grafana logs its logged that grafana responded with 403.

Expected behavior
It should pause all alerts in one go.

Software:

  • Grafana: v6.2.4
  • Hubot: latest
  • Adapter: Slack, or Any
  • Node:
  • NPM:

Panel ID is not the same as the Grafana panel ID

Hubot Grafana supports the concept of panel ID, where a query like hubot graf db graphite-carbon-metrics:3 returns the third panel of a particular dashboardby iterating through each panel until it finds the Nth one.

This is a little unintuitive. I would expect this value to match the panel ID in Grafana which is used to construct the URL (panelId=#{panel.id}). Using position rather than ID is actually a little inflexible, especially when referencing large overview dashboards that are being tweaked over time. This can lead to saved aliases from becoming broken at inconvenient times.

Since I don't want to necessarily break backwards compatibility, I am not sure how both formats can be supported. Perhaps something along the lines of graph db systems-overview:id34 to represent the panel id?

Cannot see the image in Slack

Hello,
I met a problem for my hubot and slack.
After configing the grafana, hubot, S3 correctly, and ask for a certain dashboard, the slack bot only give me a link to the dashboard, without the dashboard screen shot image.

I looked for the S3 buckets, for every link, it indeed store a "png" file, but their content is json like below:

image

I do not know how to act, could anyone help please?

Software:

  • Grafana: v5.1.0
  • Hubot: 3.1.1
  • Adapter: Slack
  • Node: 8.9.1
  • NPM: 5.5.1

Missing Legends

Hi Team,

First of thanks for that great tool.

We have integrated grafana with hubot to fetch graphs on slack, but with all graphs we have noticed strange behavior that we are not able see legends in reverend image.
Attaching image below
image

Kindly help me to know what i am missing here.

-Rohit

Can only receive 1 image by each query which queries all panels in the dashboard

Describe the bug

Before 2.5.2, when there are more than one panel in dashboard and query by below message, I can get multiple images.
hubot graf db <dashboard-name>
But in version 3+, I can only get exactly 1 image.
hubot graf db <dashboard-uid>

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a dashboard with multiple panels
  2. hubot graf db <dashboard-uid>
  3. Can only get 1 message in my channel

Expected behavior
Should receive all the images from the dashboard.

Software:

  • Grafana: 8.3.4
  • Hubot-Grafana: 3.0.1
  • Hubot: 3.3.2
  • Adapter: Slack

Additional context
I have noticed that in this version, there is a return for robot.respond .
Also a corresponding unit test on the next commit.
It seem you did want to return only first panel.
I am not sure the reason for adding this (maybe due to performance?), but I am thinking about whether this can be controlled by a configuration?
For example maybe can use HUBOT_GRAFANA_MAX_RETURNED_DASHBOARDS, to make the number of returned dashboard can be controlled.
And user can query multiple panels with only 1 query.

Look forward to your response. And thanks for the powerful tool :)

Spring Cleaning 2018

The following checklist is for all of the Hubot packages I maintain.

README.md

  • Badges (underneath title)
[![npm version](https://badge.fury.io/js/hubot-PACKAGE_NAME.svg)](http://badge.fury.io/js/hubot-PACKAGE_NAME) [![Build Status](https://travis-ci.org/stephenyeargin/hubot-PACKAGE_NAME.png)](https://travis-ci.org/stephenyeargin/hubot-PACKAGE_NAME)
  • Configuration options

package.json

  • author
  "author": "Stephen Yeargin <[email protected]>",
  • repository
  "repository": {
    "type": "git",
    "url": "git://github.com/stephenyeargin/hubot-PACKAGE_NAME.git"
  },
  • bugs
  "bugs": {
    "url": "https://github.com/stephenyeargin/hubot-PACKAGE_NAME/issues"
  },
  • peerDependencies
  "peerDependencies": {
    "hubot": ">=2 <10 || 0.0.0-development"
  },
  • husky configuration
  "scripts": {
    "test": "grunt test",
    "precommit": "npm test",
    "prepush": "npm test"
  }

Gruntfile.js

  • additionalFiles
        additionalFiles: ['package-lock.json']

.travis.yml

  • TravisCI configuration
language: node_js
sudo: false
notifications:
  email: false
node_js:
  - "8" # stable
  - "6" # LTS
  - "4" # maintenance
cache:
  directories:
- node_modules

Slack file upload support

Feature request for this module to also support Slack when it comes to uploading the images. I've already created a fork with the required changes (hubot-grafana-slack), but it'd be fantastic to see them merged in if others would find it useful. I've implemented it in much the same way as S3 support, checking for a Slack token which informs the module to upload the file to the relevant Slack instead. Currently still have to fix up a test script for my changes but it's working well for my uses so far.

Upgrade from 2.5.2 to 3.0.1: dashboards can't be accessed by slug anymore

๐Ÿ‘‹ Hi, first of all: great plugin for Hubot! We have been using it for a while now and it helps us a lot.

After upgrading I noticed I got messages like: Try your query again with RYWWhopGk instead of jarvis-sre-dashboard-by-kz

As we use a generator the RYWWhopGk will change over time, so we've became used to using the slug jarvis-sre-dashboard-by-kz. Is there a way for us to keep using commands like graf db jarvis-sre-dashboard-by-kz:panel-2 now-1h now width=1400. Is there a config value to reactivate this feature again? I would be willing to implement it myself if needed.

Is your feature request related to a problem? Please describe.
Version 3 seems to use an ID, version 2 allows the slug of a dashboard.

Describe the solution you'd like
I would love to have an environment flag to enable the feature again.

Describe alternatives you've considered
Nothing so far, but would love to contribute.

Additional context
N/A

hubot grafana ssl issue

Getting this error after installing the module:

[Tue Nov 01 2016 15:21:05 GMT-0700 (PDT)] ERROR { Error: unable to verify the first certificate
at Error (native)
at TLSSocket. (_tls_wrap.js:1060:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:584:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

Any ideas?

ERROR SyntaxError: Unexpected token < in JSON at position 0

Describe the bug
I'm trying to get Grafana dashboard to slack API using hubot. Once tyoe @jarvis-bot graf list, its giving following error

ubuntu@ubuntu:~/hubot$ HUBOT_SLACK_TOKEN=xoxb-XXXXXXXXXXXXXXXXXXXX ./bin/hubot --adapter slack
audited 168 packages in 4.264s

2 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

[Sun Jan 03 2021 08:15:18 GMT+0000 (Coordinated Universal Time)] INFO hubot-slack adapter v4.8.1
warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.
warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.
[Sun Jan 03 2021 08:15:19 GMT+0000 (Coordinated Universal Time)] INFO Logged in as @jarvis-bot in workspace Team-PSMT
[Sun Jan 03 2021 08:15:20 GMT+0000 (Coordinated Universal Time)] INFO Connected to Slack RTM
[Sun Jan 03 2021 08:15:20 GMT+0000 (Coordinated Universal Time)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sun Jan 03 2021 08:15:21 GMT+0000 (Coordinated Universal Time)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Sun Jan 03 2021 08:16:06 GMT+0000 (Coordinated Universal Time)] ERROR SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (:null:null)
at /home/ubuntu/hubot/node_modules/hubot-grafana/src/grafana.coffee:428:7, :424:21
at IncomingMessage. (/home/ubuntu/hubot/node_modules/scoped-http-client/src/index.js:95:22)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

To Reproduce
Steps to reproduce the behavior:
1.Installed proetheus, node_exporter as service and installed grafana with image render plugin using docker-compose in a Raspberry pi 4 (armv8)

  1. See error

Expected behavior
getting grafana dashboard without error

Screenshots
image
image

Software:

  • Grafana: v7.3.6
  • Hubot: 3.3.2
  • Adapter: Slack
  • Node: v14.15.3
  • NPM: 6.14.9

Switch to native S3 library to use IAM for permissions

It looks like the library you're using to interact with S3, knox, is not maintained, and is therefore missing common functionality like IAM role support. If you switched to using the AWS SDK, you would be able to get that functionality without any additional effort.

HTML Snippets in Slack on Image Render Error

Describe the bug
When requesting a dashboard through Slack, the hubot returns HTML snippets instead of images.

To Reproduce
Steps to reproduce the behavior:

  1. Data source 'elasticsearch'
  2. Command entered 'graf db dashboardname'
  3. The bot posts HTML snippets instead of images

Expected behavior
I expected to see images and not HTML snippets.

Screenshots
Window capture 3

Software:

  • Grafana: 6.2.0
  • Hubot: 3.3.2
  • Adapter: Slack
  • Node: 10.16.0
  • NPM: 6.9.0

I'm not sure if the issue is with Grafana not returning what the hubot-grafana plugin expects or an issue with hubot-grafana itself. I'm happy to help diagnose and write a PR if the issue turns out to be in hubot-grafana.

PNG of login screen only

Hi! We are having a curious issue. When issuing a command, the hubot script connects correctly to grafana and calls the correct dashboard, as can be seen via HUBOT_LOG_LEVEL=debug:

title: 'Coresites Performance',
  tooltip: { shared: true, value_type: 'cumulative' },
  type: 'graph',

But the screenshot we get uploaded is only of the Grafana login screen for some reason. Any ideas?

Whitespace at the end of query changes its behaviour

When executing command like hubot graf db test_db with whitespace at the end, it will treat is as an extra empty string argument, which results in generating link to the picture with empty from parameter(for example /?panelId=2&fullscreen&from=&to=now), instead of default query time range value.

[Task] Implement code coverage badge

Coverage Status

I fought with this for a while and it wasn't as straightforward as I thought it would be. The root issue is that I'm trying to check all these boxes before it will work properly:

  • uses Coveralls (not aware of another reporting service that supports node and integrates with Travis)
  • can report on CoffeeScript (most are built for JavaScript)
  • ties into the Grunt command (we default to using grunt test, so we would want grunt coverage)
  • executes alongside Travis CI run (branch builds already run tests)

The objective with code coverage is to a) monitor the test coverage differences with new features added and b) advertise that this package has decent test coverage.

I may come back to this, but anyone who wants to take a swing at it is more than welcome.

Support for Grafana 5.0

Hello,
I try to use grafana hubot script with no luck

My Grafana version is 5.0
Hubot-gafana 1.8.0

Here are the problems I noticed so far:

  • following error when trying to display a db : Cannot read property 'length' of undefined
  • graf list return dbs and folders, if I try to display a folder I get an error Cannot read property 'list' of undefined
  • Search by slug is deprecated and will be removed, search by uid should be used instead

I get these error

Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'hubot graf db dotann-prod'
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG [ 'hubot graf db dotann-prod',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: 'dotann-prod',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: undefined,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: index: 0,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: input: 'hubot graf db dotann-prod' ]
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG dotann-prod
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG { from: 'now-6h', to: 'now' }
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG []
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG false
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG false
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG false
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG { meta:
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: { type: 'db',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: canSave: true,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: canEdit: true,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: canAdmin: false,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: canStar: true,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: slug: 'dotann-prod',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: url: '/d/-RR2kFekk/dotann-prod',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: expires: '0001-01-01T00:00:00Z',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: created: '0001-01-01T11:05:48+11:05',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: updated: '2018-03-07T09:15:44+11:00',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: updatedBy: 'admin',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: createdBy: 'admin',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: version: 9,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: hasAcl: false,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: isFolder: false,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: folderId: 9,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: folderTitle: 'NEED',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: folderUrl: '/dashboards/f/T9wR7L6kz/need' },
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: dashboard:
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: { annotations: { list: [Object] },
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: editable: true,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: gnetId: null,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: graphTooltip: 0,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: id: 3,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: links: [],
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: panels: [ [Object], [Object] ],
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: refresh: '5m',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: schemaVersion: 16,
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: style: 'dark',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: tags: [],
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: templating: { list: [] },
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: time: { from: 'now-6h', to: 'now' },
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: timepicker: { refresh_intervals: [Object], time_options: [Object] },
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: timezone: '',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: title: 'Dotann PROD',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: uid: '-RR2kFekk',
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: version: 9 } }
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] DEBUG []
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: [Thu Mar 08 2018 02:16:51 GMT+0000 (UTC)] ERROR TypeError: Cannot read property 'length' of undefined
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at /home/hubot/node_modules/hubot-grafana/src/grafana.coffee:167:7
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at /home/hubot/node_modules/hubot-grafana/src/grafana.coffee:314:14
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at IncomingMessage. (/home/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at emitNone (events.js:72:20)
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at IncomingMessage.emit (events.js:166:7)
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at endReadableNT (_stream_readable.js:923:12)
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at nextTickCallbackWith2Args (node.js:511:9)
Mar 08 13:16:51 dbk-apldev-01v docker[10406]: at process._tickCallback (node.js:425:17)

Per room/channel configuration

Is your feature request related to a problem? Please describe.
Current hubot-grafana only support one configuration, when several configurations are required, multiple bots needs to be instantiated

Describe the solution you'd like
I propose to add new commands to set the configuration and use robot.brain to store it. When request will come in the appropriate configuration value will be retrieved from the brain.

Describe alternatives you've considered
None

Additional context
None

I'm considering to prototype it and make a PR however I'm not much skilled on JS/Coffeescript so i would definitely need reviews of it :)
Does it has a chance to be accepted?

Unable to upload to S3

Hi,
I'm trying to make hubot-grafana to upload graphs to S3, but I only get these errors

[Mon Jun 27 2016 18:31:09 GMT+0700 (ICT)] ERROR Upload Error Code: 307
[Mon Jun 27 2016 18:31:09 GMT+0700 (ICT)] ERROR Upload Error Code: 307
[Mon Jun 27 2016 18:31:10 GMT+0700 (ICT)] ERROR Upload Error Code: 307
[Mon Jun 27 2016 18:31:10 GMT+0700 (ICT)] ERROR Upload Error Code: 307

Here's my config

export HUBOT_GRAFANA_HOST=https://my-grafana.com
export HUBOT_GRAFANA_API_KEY=MY-API-KEY
export HUBOT_GRAFANA_S3_BUCKET=grafana-graphs
export HUBOT_GRAFANA_S3_ACCESS_KEY_ID=MY-ACCESS-KEY-ID
export HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY=MY-SECRET-ACCESS-KEY
export HUBOT_GRAFANA_S3_REGION=ap-southeast-1

When I tested the credential with awscli, it worked.
Did I do anything wrong or miss anything?

TimeZone support

Is your feature request related to a problem? Please describe.
Grafana supports time-zones. Let's expose it as well. This might fix some of my dashboards.

Describe the solution you'd like
I'll add time-zone support to the imageUrl. It can be explicitly added as tz=, just like width=. Or it can be set globally with the env var HUBOT_GRAFANA_DEFAULT_TIME_ZONE.

Describe alternatives you've considered
n/a

Additional context
n/a

Notes
I'll send a pull request with the feature.

[Grafana 5] Search by slug deprecated

Extracting part of #66 into this ticket.

Search by slug is deprecated and will be removed, search by uid should be used instead

HTTP API

The following operations have been deprecated and will be removed in a future release:

  • GET /api/dashboards/db/:slug -> Use GET /api/dashboards/uid/:uid instead
  • DELETE /api/dashboards/db/:slug -> Use DELETE /api/dashboards/uid/:uid instead

The following properties have been deprecated and will be removed in a future release:

  • uri property in GET /api/search -> Use new url or uid property instead
  • meta.slug property in GET /api/dashboards/uid/:uid and GET /api/dashboards/db/:slug -> >Use new meta.url or dashboard.uid property instead

Reference: https://github.com/grafana/grafana/blob/master/CHANGELOG.md#http-api (Under 5.0.0-beta1)

404 response code

Hi

Im trying to implement the hubot-grafana in my hubot-slack but I'm getting only 404 response codes.
My hubot-slack \ grafana is on docker container which is just for FYI.

When I use the hubot graf list command, I'm getting my dashboard list, but when I'm trying to retrieve a certain dashboard im getting the error below from the hubot logs,

2016/01/30 23:58:31 [I] PhantomRenderer::renderToPng url https:///yy.xx.co/dashboard-solo/db/home?panelId=3&width=1000&height=500&from=now-6h&to=now
2016/01/30 23:58:46 [I] Completed EXT_IP - "GET /render/dashboard-solo/db/home/ HTTP/1.1" 404 Not Found 19 bytes in 15141680us

The link in the Slack is the right link but, PNG file in the S3 is the 404 error code.

My Grafana version is 2.6.0 and also hubot npm version is the latest.

Does anyone knows what can be the problem here?

D.

Image uploads to S3 bucket with zero size.

Hi
I am successfully able to put .png file to S3 bucket , but size is zero bytes.

[Fri May 19 2017 05:21:52 GMT+0000 (UTC)] DEBUG Uploading file: 27032 bytes, content-type[image/png]
[Fri May 19 2017 05:21:52 GMT+0000 (UTC)] DEBUG filename
[Fri May 19 2017 05:21:52 GMT+0000 (UTC)] DEBUG graphs/59515bcabb9abb59c31ab44a0b3557635238aa10.png
[Fri May 19 2017 05:21:55 GMT+0000 (UTC)] DEBUG inside response

But _header: 'POST / /graphs/59515bcabb9abb59c31ab44a0b3557635238aa10.png upload in S3 is zero bytes,

Can anyone say where does it store the png file locally ?

Hubot Login to Grafana to fetch PNG

Hey there,

I am doodling around with hubot-rocketchat and I am quite far.
Thing is, that if I query for a graph only the link is put into the chat. I guess that's how it's supposed to work, the rocketchat code should evaluate the link to present the actual picture.
When clicking the link I get to the Login-Page. I suppose that's the issue here:
The PNG could not be fetched since it's behind the 'login'. Am I right.

Current Template Overriding Specified Template Value

Hi. I have a dashboard monitoring-default, with a single variable, $server. When asking hubot-grafana for a specific server's load, I use the following command: graf db monitoring-default:load server=www-03.example.com now-1h.

My expectation is that Hubot's response would begin with "www-03.example.com load: ", but instead a different (but valid) variable value is shown. This happens to be the same variable value that loads by default when the monitoring-default dashboard is loaded in a browser (the current value in the dashboard json).

I am unsure of the nuances and more general use-cases for templates with hubot-grafana, but have successfully been able to achieve the desired result here: criticalmass@dfb4084. If you find this approach acceptable, I can create a PR with the changes.

Cheers!

[Idea] Split core Grafana interactions into its own node module

In its present state, this Hubot package builds all of the requests to a Grafana instance and handles the interaction with the user. Ideally, these should be two separate modules.

node-grafana (new)

Low-level HTTP(S) request library that handles authentication and common queries against the API (retrieve a list of dashboards, grab a specific dashboard's data, build the URLs for images, etc.).

grafana-hubot (this package)

A much lighter-weight wrapper that uses a configured instance of node-grafana to query the API. It also would handle the various adapters for uploading images, such as S3, Slack, HipChat, etc.


This should cut down the total lines of code in this package while giving Hubot and other node developers an alternative to relying on the conventions of this package.

/cc #47

Error getting dashboard

Hello,

First, thanks for this project ! ๐Ÿ‘

Grafana version : 2.1.3

I have an error trying to get panels :

Julien Syx [11:30] 
hubot graf list

hubotBOT [11:30] 
Available dashboards:
- test-machine: Test machine
- test-dashboard: Test dashboard

Julien Syx [11:31] 
hubot graf db test-machine

Then hubot answers nothing and in the log I get :

[Fri Oct 16 2015 11:31:30 GMT+0200 (CEST)] ERROR TypeError: Cannot read property 'text' of undefined
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:113:11, <js>:82:65
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:202:14, <js>:178:16
  at IncomingMessage.<anonymous> (/home/admin/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at emitNone (events.js:72:20)
  at IncomingMessage.emit (events.js:166:7)
  at endReadableNT (_stream_readable.js:903:12)
  at doNTCallback2 (node.js:439:9)
  at process._tickCallback (node.js:353:17)

But test-dahboard works correctly. I thought it was the parameter $SERVER which was missing, but adding this parameter give exactly the same error

Any idea about this please ?
Thanks

Using with grafana server https self signed

When I intend to use with https grafana server(self signed) I experiment this error:

GMT+0300 (EEST)] ERROR { Error: self signed certificate
at TLSSocket. (_tls_wrap.js:1105:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
code: 'DEPTH_ZERO_SELF_SIGNED_CERT' }

Not rendering all repeating graphs based on dashboard template variable

I'm not sure if this is a bug with this script or somewhere in Grafana. I have a dashboard set up with a template variable for server service type and then another template variable for server name (list built from service type variable). The server variable is a multi-select type and defaults to "All". Graphs for each server are then created by repeating rows (as opposed to repeating graphs)

When I pass the "service" variable via the script, no more than 2 graphs are rendered. Here's an example:

graph db system:cpu service=example

If that service contains three servers, I only get graphs from the first two servers. There are no errors in either the hubot or grafana logs, and the grafana log indicates that only two graphs were rendered:

t=2017-01-13T17:53:29+0000 lvl=info msg=Rendering logger=png-renderer path="dashboard-solo/db/system?panelId=9&width=1000&height=500&from=now-6h&to=now&var-service=example"
t=2017-01-13T17:53:29+0000 lvl=info msg=Rendering logger=png-renderer path="dashboard-solo/db/system?panelId=12&width=1000&height=500&from=now-6h&to=now&var-service=example"

Grafana 7: Full screen leads to localhost:3000 redirect

Describe the bug
When a dashboard is rendered, a link to the "fullscreen" dashboard is generated as well. This link looks like this:

https://my.dashboards.link/dashboard/db/team-tooling/?panelId=1&fullscreen&from=now-6h&to=now

But when I click it, it redirects to:

http://localhost:3000/d/lHzvLGpGk/team-tooling?from=now-6h&to=now&viewPanel=1

But when I change the link to this, it works:

https://my.dashboards.link/dashboard/db/team-tooling/?panelId=1&viewPanel=1&from=now-6h&to=now

Here I removed the fullscreen parameter. I added a viewPanel= parameter.

We're running Grafana v7.1.3 (5723d951af)

To Reproduce
Steps to reproduce the behavior:

  1. Grafana 7
  2. Request panel through bot
  3. Click on link in the Slack message

Expected behavior
I would expect the link to work. By changing the link it works.

Screenshots
N/A

Work-a-round
I've patched the msg.send method to intercept the message to Slack and changed the message:

            let item = payload.attachments[0];

            item.fallback = item.fallback.replace("&fullscreen", "");
            item.title_link = item.title_link.replace("&fullscreen", "");

            item.fallback = item.fallback.replace(/panelId=(\d+)/, "panelId=$1&viewPanel=$1");
            item.title_link = item.title_link.replace(/panelId=(\d+)/, "panelId=$1&viewPanel=$1");

Software:

  • Grafana: Grafana v7.1.3 (5723d951af)
  • Hubot: 3.3.2
  • Adapter: Slack
  • Node: v12.19.0
  • NPM: 6.14.8

Additional context
N/A

When calling multiple graphs, only 2 show up

Describe the bug
Saying "graf db:" used to show all available graphs. Now it displays all the titles but only shows the graphs for two.

To Reproduce
Steps to reproduce the behavior:

  1. Create a dashboard named "db" with multiple graphs
  2. Call hubot in Slack

Expected behavior
Usually, all graphs and their titles would be displayed.

Screenshots
https://imgur.com/a/bXoGuFM

Software:
Grafana: v6.3.X
Hubot: v3.3.2
Adapter: Slack

Additional context
This was working until the latest grafana update a week or two ago

Rocket.chat file upload support

My use case is to use Rocketchat.chat to store png files instead of S3.
This way all my files uploaded in Rocketchat are managed the same way.

I implemented this feature the same way as Slack uploads

Bar Guage not rendered correctly

Describe the bug
When calling a Bar Guage graph in Slack, the text and color bars are badly sized instead of normally being uniform. One stat's number is huge the others are smaller and the colored bar is thinner. Like it just needs another .1s to finish rendering properly.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Bar Graph visualization with a few (3-6) stats in it.
  2. Use any "style" it's messed up in different ways for different styles.
  3. In slack, call @hubot_grafana graf db:my_bar_guage

Expected behavior
The bar guage is normally rendered as it appears in grafana - the text and colored bars of the stats present are all uniform.

Screenshots
pending

Software:

  • Grafana: v6.3.X
  • Hubot: v3.3.2
  • Adapter: Slack

Additional context
Add any other context about the problem here.

Images not rendering from S3

Hi,

I'm getting below error while executing "graf db dashboard-name" command in Slack.

[Thu Oct 12 2017 03:11:52 GMT+0000 (UTC)] ERROR TypeError: msg.replace is not a function
at SlackBot.send (/root/hubot/node_modules/hubot-slack/src/slack.coffee:229:47, :278:19)
at runAdapterSend (/root/hubot/node_modules/hubot/src/response.coffee:82:34, :87:50)
at allDone (/root/hubot/node_modules/hubot/src/middleware.coffee:44:37, :34:16)
at /root/hubot/node_modules/async/lib/async.js:274:13
at Object.async.eachSeries (/root/hubot/node_modules/async/lib/async.js:142:20)
at Object.async.reduce (/root/hubot/node_modules/async/lib/async.js:268:15)
at /root/hubot/node_modules/hubot/src/middleware.coffee:49:7, :37:22
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

I have configured S3 with Grafana and images are pulled to S3. graf list command is working as expected. Any idea?

ERROR SyntaxError: Unexpected token < in JSON at position 0

[Tue Jul 28 2020 11:18:49 GMT+0800 (China Standard Time)] ERROR SyntaxError: Unexpected token < in JSON at position 0
  at JSON.parse (<anonymous>:null:null)
  at /data/myhubot/node_modules/hubot-grafana/src/grafana.coffee:423:7, <js>:420:21
  at IncomingMessage.<anonymous> (/data/myhubot/node_modules/scoped-http-client/src/index.js:95:22)
  at IncomingMessage.emit (events.js:203:15)
  at endReadableNT (_stream_readable.js:1145:12)
  at process._tickCallback (internal/process/next_tick.js:63:19)

The environment is as follows:

# node -v
v10.22.0
grafana 7
centos 7

Excuting an order:
hubot graf list
why๏ผŸ

Allow users to alias dashboard panels / timeframes

Using the default robot.brain (often backed by Redis or some other storage), allow the user to alias complex queries. The alias would recall the stored data and replay it as if the user had entered it themselves.

hubot grafana alias logins = dashboard webapp-overview:3 now-1h now
hubot grafana alias logins
hubot grafana alias list

Mentioned in grafana/grafana#2206 (comment), /cc @torkelo

Add command to list Dashboards

This is such an obvious thing; cannot believe I left it out. ๐Ÿ˜€

User> hubot grafana
Hubot> Available Dashboards:
Hubot> - dashboard-one : Dashboard One
Hubot> - dashboard-two : Dashboard Two
Hubot> - dashboard-three : Dashboard Three

[Rocketchat] _ERROR SyntaxError: Unexpected token

Describe the bug
when running hubot graf db test123 hubot-rocketchat is showing ERROR SyntaxError: Unexpected token <

My grafana url is https://test.tools.**.**/grafana

I get below log from hubot container
DEBUG [ 'hubot graf db test123',
'test123',
undefined,
index: 0,
input: 'hubot graf db test123' ]

DEBUG { meta:
{ type: 'db',
canSave: false,
canEdit: false,
canAdmin: false,
canStar: false,
slug: 'test123',
url: '/grafana/d/VKZr7u9mz/test123',
expires: '0001-01-01T00:00:00Z',
created: '2019-02-27T21:26:21Z',
updated: '2019-02-27T21:26:21Z',
updatedBy: 'admin',
createdBy: 'admin',
version: 1,
hasAcl: false,
isFolder: false,
folderId: 0,
folderTitle: 'General',
folderUrl: '',
provisioned: false },
dashboard:
{ annotations: { list: [Object] },
editable: true,
gnetId: null,
graphTooltip: 0,
hideControls: false,
id: 26,
links: [],
panels: [ [Object] ],
schemaVersion: 16,
style: 'dark',
tags: [],
templating: { list: [] },
time: { from: 'now-6h', to: 'now' },
timepicker: { refresh_intervals: [Object], time_options: [Object] },
timezone: '',
title: 'test123',
uid: 'VKZr7u9mz',
version: 1 } }

DEBUG { cacheTimeout: null,
colorBackground: false,
colorValue: false,
colors: [ '#299c46', 'rgba(237, 129, 40, 0.89)', '#d44a3a' ],
format: 'none',
gauge:
{ maxValue: 100,
minValue: 0,
show: false,
thresholdLabels: false,
thresholdMarkers: true },
gridPos: { h: 9, w: 12, x: 0, y: 0 },
id: 2,
interval: null,
links: [],
mappingType: 1,
mappingTypes:
[ { name: 'value to text', value: 1 },
{ name: 'range to text', value: 2 } ],
maxDataPoints: 100,
nullPointMode: 'connected',
nullText: null,
postfix: '',
postfixFontSize: '50%',
prefix: '',
prefixFontSize: '50%',
rangeMaps: [ { from: 'null', text: 'N/A', to: 'null' } ],
sparkline:
{ fillColor: 'rgba(31, 118, 189, 0.18)',
full: false,
lineColor: 'rgb(31, 120, 193)',
show: false },
tableColumn: '',
targets:
[ { expr: '150',
format: 'time_series',
intervalFactor: 1,
refId: 'A' } ],
thresholds: '',
title: 'test123',
type: 'singlestat',
valueFontSize: '80%',
valueMaps: [ { op: '=', text: 'N/A', value: 'null' } ],
valueName: 'avg' }
[Wed Feb 27 2019 23:02:18 GMT+0000 (UTC)] ERROR SyntaxError: Unexpected token <
at Object.parse (native)
at Request._callback (/home/hubot/node_modules/hubot-grafana/src/grafana.coffee:485:27)
at Request.self.callback (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:185:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request. (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:1161:10)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at IncomingMessage. (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:1083:12)
at IncomingMessage.g (events.js:260:16)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:923:12)
at nextTickCallbackWith2Args (node.js:511:9)
at process._tickCallback (node.js:425:17)

To Reproduce
Create a small dashboard in grafana. Grafana has url /grafana.
Enabled anonymus in grafana

Started hubot-rocketchat with below options
- name: EXTERNAL_SCRIPTS
value: "hubot-help,hubot-pugme,hubot-shipit,hubot-grafana"
- name: HUBOT_GRAFANA_HOST
value: "http://tools.tools.****.####/grafana/"

In rocketchat room
when i do hubot graf db anyname
I get the above error. But graf list command works fine

Expected behavior
Image should be shown in rocketchat

Screenshots
If applicable, add screenshots to help explain your problem.

Software:

  • Grafana: 5.4.3
  • Hubot: 2.19.0
  • Adapter: rocketchat
  • Node: v4.8.3
  • NPM: 2.15.11

Additional context
We are running rocketchat and grafana in kubernetes.

ECONNREFUSED with API key.

I'm using a Grafana API key and I am unable to connect to the instance. I keep erroring out with the following:

hubot> hubot graf list
hubot> [Sun Feb 07 2016 06:54:26 GMT+0000 (UTC)] DEBUG Message 'hubot graf list' matched regex //^\s*[@]?hubot[:,]?\s*(?:(?:grafana|graph|graf) list\s?(.+)?)/i/; listener.options = { id: null }
[Sun Feb 07 2016 06:54:26 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'hubot graf list'
[Sun Feb 07 2016 06:54:26 GMT+0000 (UTC)] ERROR { [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }
[Sun Feb 07 2016 06:54:26 GMT+0000 (UTC)] DEBUG false
[Sun Feb 07 2016 06:54:26 GMT+0000 (UTC)] DEBUG false

I've tested the API key using curl and it works fine.

I did add some console.log statements to inspect variables and I noticed that the authHeader has some odd formatting around the Authorization:

{ Accept: 'application/json',
  Authorization: 'Bearer eyJrIjoiWXXX...XXX0=' }

I noticed that the "Bearer" statement and the key are surrounded by single quotes. That seems a bit unusual, but I may be missing something.

Thanks in advance.

Upload image with guid name to S3 before posting to hubot

To make this work with all clients of Hipchat and Slack the image needs to be publicly accessible, most Grafana installs will be behind firewalls/dmz so the best option is to upload the image to an s3 bucket and link to that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.