Skip to content

A proxy server that receives requests from a grafana instance, parses the request into commands made to the Scalyr api and returns the scalyr data in a grafana-friendly format

License

Notifications You must be signed in to change notification settings

AdknownInc/grafana-scalyr-proxy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

grafana-scalyr-proxy-server

A proxy server that receives requests from a grafana instance, parses the request into commands made to the Scalyr api and returns the scalyr data in a grafana-friendly format

Installation

Get the Plugin

Ensure you've cloned https://github.com/AdknownInc/grafana-scalyr-datasource-plugin locally.

Config

Docker Compose

Modify the docker-compose.yml to:

  • (optional) contain a Scalyr Read API key generated by your Scalyr account.
    • Replace the SCALYR_READ_KEY value with your key
    • This is used as a fall back if the key is not sent from the plugin (see below)
  • Change the volume that contains the plugin to point your locally cloned plugin's directory. My development setup looks like this:
    • ~
      • projects/github.com
        • grafana-scalyr-proxy-server
        • grafana-scalyr-datasource-plugin
    • For that reason, my volume is pointing to "../../grafana-scalyr-datasource-plugin"
  • Optional: Modify DOCKER_HOST_NAME=grafanaProxy to contain a hostName that corresponds with your company's serverHost name standards.
    • We'll be using this value later to verify it was installed correctly

Scalyr - api_key.json

Modify the file scalyr/agent.d/api_key.json to also have your Scalyr api key in that file.

Install

Run docker-compose up while in the docker-container directory

In your browser, navigate to http://localhost:8000 and login to grafana username: admin password: admin

Add a datasource, the datasource'ss name is Scalyr Enter "Scalyr" for the Name

In the HTTP section, enter "http://web:8080" as the URL Set "Access" to "proxy"

Click "Save & Test"

You should see this

Plugin Configured Screenshot

After that, create a new dashboard and add a panel Change the Data Source to Scalyr

Enter "First" as the target type (this can be any non-empty value)

Enter $serverHost = 'grafanaProxy' as the Filter

Change the Graph Function to Count

Change the Interval (seconds) to 30

At the end, you'll see this:
First Graph Config

And that's it, you have configured the scalyr data source.

Some sample datasources and dashboards have been provisioned for your viewing pleasure

Optional Configuration

View complex query parts

If checked in the data source configuration, a flag will be set that will tell the proxy server to return each part of a complex query

It may take some time to update as it needs to wait for response from the server

View each part by checking the box in graph view

Complex Query Parts

Scalyr read/write keys

Read and write keys can be provided in the plugin configuration and will be used over environment variables

These only need to be set once

Scalyr Keys

Alerts - ElasticSearch Hack

At the moment, grafana does not support alerts of custom datasource plugins. This is because alerts call the backend of grafana and require a custom go function handler to run in response to the alert endpoint being hit.

To allow the use of alerts, this backend will support an elasticsearch datasource plugin to allow alerts. It will require your scalyr queries to be in complex query format, but you'll get grafana alerts out of it.

ElasticsearchFaker install

Configure

Configure an Elasticsearch datasource with the following values

Note: This method required that keys be set in environment

Fake Elastic Search Config

Set up Alerts

Scalyr complex numeric queries can be sent through the data source like so

A README is provided in the response for additional tweaking. Simply click "Query Inspector" to see it

Fake Elastic Search Graph

From there you can set up alerts as you normally would

Fake Elastic Search Alert

TODO:

  • Add a Contribution guide
  • Add further documentation about numeric vs facet vs complex
  • Modify complex queries from using regex to using a grammar + parser so that all queries supported by Scalyr can be entered into grafana
  • Add authentication

Server Configuration

Services/Components

  • PHP 7.1

In it's current form, the docker-compose file is setup to also bootup a grafana instance. Unsure if it will stay this way.

About

A proxy server that receives requests from a grafana instance, parses the request into commands made to the Scalyr api and returns the scalyr data in a grafana-friendly format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages