mirror of https://github.com/grafana/grafana
Remove guides (#23589)
parent
c796f70a3b
commit
f48d444a14
@ -1,166 +0,0 @@ |
||||
+++ |
||||
title = "Running Grafana behind a reverse proxy" |
||||
description = "Guide for running Grafana behind a reverse proxy" |
||||
keywords = ["grafana", "nginx", "documentation", "haproxy", "reverse"] |
||||
type = "docs" |
||||
[menu.docs] |
||||
name = "Running Grafana behind a reverse proxy" |
||||
parent = "tutorials" |
||||
weight = 1 |
||||
+++ |
||||
|
||||
|
||||
# Running Grafana behind a reverse proxy |
||||
|
||||
It should be straight forward to get Grafana up and running behind a reverse proxy. But here are some things that you might run into. |
||||
|
||||
Links and redirects will not be rendered correctly unless you set the server.domain setting. |
||||
```bash |
||||
[server] |
||||
domain = foo.bar |
||||
``` |
||||
|
||||
To use sub *path* ex `http://foo.bar/grafana` make sure to include `/grafana` in the end of root_url. |
||||
Otherwise Grafana will not behave correctly. See example below. |
||||
|
||||
## Examples |
||||
Here are some example configurations for running Grafana behind a reverse proxy. |
||||
|
||||
### Grafana configuration (ex http://foo.bar) |
||||
|
||||
```bash |
||||
[server] |
||||
domain = foo.bar |
||||
``` |
||||
|
||||
### Nginx configuration |
||||
|
||||
Nginx is a high performance load balancer, web server and reverse proxy: https://www.nginx.com/ |
||||
|
||||
#### Nginx configuration with HTTP and Reverse Proxy enabled |
||||
```nginx |
||||
server { |
||||
listen 80; |
||||
root /usr/share/nginx/html; |
||||
index index.html index.htm; |
||||
|
||||
location / { |
||||
proxy_pass http://localhost:3000/; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Grafana configuration with hosting HTTPS in Nginx (ex https://foo.bar) |
||||
|
||||
```bash |
||||
[server] |
||||
domain = foo.bar |
||||
root_url = https://foo.bar |
||||
``` |
||||
|
||||
#### Nginx configuration with HTTPS, Reverse Proxy, HTTP to HTTPS redirect and URL re-writes enabled |
||||
|
||||
Instead of http://foo.bar:3000/?orgId=1, this configuration will redirect all HTTP requests to HTTPS and re-write the URL so that port 3000 isn't visible and will result in https://foo.bar/?orgId=1 |
||||
|
||||
```nginx |
||||
server { |
||||
listen 80; |
||||
server_name foo.bar; |
||||
return 301 https://foo.bar$request_uri; |
||||
} |
||||
|
||||
server { |
||||
listen 443 ssl http2; |
||||
server_name foo.bar; |
||||
root /usr/share/nginx/html; |
||||
index index.html index.htm; |
||||
ssl_certificate /etc/nginx/certs/foo_bar.crt; |
||||
ssl_certificate_key /etc/nginx/certs/foo_bar_decrypted.key; |
||||
ssl_protocols TLSv1.2; |
||||
ssl_ciphers HIGH:!aNULL:!MD5; |
||||
|
||||
location / { |
||||
rewrite /(.*) /$1 break; |
||||
proxy_pass http://localhost:3000/; |
||||
proxy_redirect off; |
||||
proxy_set_header Host $host; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Examples with **sub path** (ex http://foo.bar/grafana) |
||||
|
||||
#### Grafana configuration with sub path |
||||
```bash |
||||
[server] |
||||
domain = foo.bar |
||||
root_url = %(protocol)s://%(domain)s/grafana/ |
||||
``` |
||||
|
||||
#### Nginx configuration with sub path |
||||
```nginx |
||||
server { |
||||
listen 80; |
||||
root /usr/share/nginx/www; |
||||
index index.html index.htm; |
||||
|
||||
location /grafana/ { |
||||
proxy_pass http://localhost:3000/; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
#### HAProxy configuration with sub path |
||||
```bash |
||||
frontend http-in |
||||
bind *:80 |
||||
use_backend grafana_backend if { path /grafana } or { path_beg /grafana/ } |
||||
|
||||
backend grafana_backend |
||||
# Requires haproxy >= 1.6 |
||||
http-request set-path %[path,regsub(^/grafana/?,/)] |
||||
|
||||
# Works for haproxy < 1.6 |
||||
# reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2 |
||||
|
||||
server grafana localhost:3000 |
||||
``` |
||||
|
||||
### IIS URL Rewrite Rule (Windows) with Subpath |
||||
|
||||
IIS requires that the URL Rewrite module is installed. |
||||
|
||||
Given: |
||||
|
||||
- subpath `grafana` |
||||
- Grafana installed on `http://localhost:3000` |
||||
- server config: |
||||
|
||||
```bash |
||||
[server] |
||||
domain = localhost:8080 |
||||
root_url = %(protocol)s://%(domain)s/grafana/ |
||||
``` |
||||
|
||||
Create an Inbound Rule for the parent website (localhost:8080 in this example) in IIS Manager with the following settings: |
||||
|
||||
- pattern: `grafana(/)?(.*)` |
||||
- check the `Ignore case` checkbox |
||||
- rewrite URL set to `http://localhost:3000/{R:2}` |
||||
- check the `Append query string` checkbox |
||||
- check the `Stop processing of subsequent rules` checkbox |
||||
|
||||
This is the rewrite rule that is generated in the `web.config`: |
||||
|
||||
```xml |
||||
<rewrite> |
||||
<rules> |
||||
<rule name="Grafana" enabled="true" stopProcessing="true"> |
||||
<match url="grafana(/)?(.*)" /> |
||||
<action type="Rewrite" url="http://localhost:3000/{R:2}" logRewrittenUrl="false" /> |
||||
</rule> |
||||
</rules> |
||||
</rewrite> |
||||
``` |
||||
|
||||
See the [tutorial on IIS URL Rewrites](http://docs.grafana.org/tutorials/iis/) for more in-depth instructions. |
||||
@ -1,139 +0,0 @@ |
||||
+++ |
||||
title = "How to integrate Hubot and Grafana" |
||||
type = "docs" |
||||
keywords = ["grafana", "tutorials", "hubot", "slack", "hipchat", "setup", "install", "config"] |
||||
[menu.docs] |
||||
parent = "tutorials" |
||||
weight = 10 |
||||
+++ |
||||
|
||||
# How to integrate Hubot with Grafana |
||||
|
||||
Grafana 2.0 shipped with a great feature that enables it to render any graph or panel to a PNG image. |
||||
No matter what data source you are using, the PNG image of the Graph will look the same |
||||
as it does in your browser. |
||||
|
||||
This guide will show you how to install and configure the [Hubot-Grafana](https://github.com/stephenyeargin/hubot-grafana) |
||||
plugin. This plugin allows you to tell hubot to render any dashboard or graph right from a channel in |
||||
Slack, Hipchat or Basecamp. The bot will respond with an image of the graph and a link that will |
||||
take you to the graph. |
||||
|
||||
> *Amazon S3 Required*: The hubot-grafana script will upload the rendered graphs to Amazon S3. This |
||||
> is so Hipchat and Slack can show them reliably (they require the image to be publicly available). |
||||
|
||||
<div class="text-center"> |
||||
<img src="/img/docs/tutorials/hubot_grafana.png" class="center"></a> |
||||
</div> |
||||
|
||||
## What is Hubot? |
||||
|
||||
[Hubot](https://hubot.github.com/) is an universal and extensible chat bot that can be used with many chat |
||||
services and has a huge library of third party plugins that allow you to automate anything from your |
||||
chat rooms. |
||||
|
||||
## Install Hubot |
||||
|
||||
Hubot is very easy to install and host. If you do not already have a bot up and running please |
||||
read the official [Getting Started With Hubot](https://hubot.github.com/docs/) guide. |
||||
|
||||
## Install Hubot-Grafana script |
||||
|
||||
In your Hubot project repo install the Grafana plugin using `npm`: |
||||
```bash |
||||
npm install hubot-grafana --save |
||||
``` |
||||
Edit the file external-scripts.json, and add hubot-grafana to the list of plugins. |
||||
|
||||
```json |
||||
[ |
||||
"hubot-pugme", |
||||
"hubot-shipit", |
||||
"hubot-grafana" |
||||
] |
||||
``` |
||||
|
||||
## Configure |
||||
|
||||
The `hubot-grafana` plugin requires a number of environment variables to be set in order to work properly. |
||||
|
||||
```bash |
||||
export HUBOT_GRAFANA_HOST=https://play.grafana.org |
||||
export HUBOT_GRAFANA_API_KEY=abcd01234deadbeef01234 |
||||
export HUBOT_GRAFANA_S3_BUCKET=mybucket |
||||
export HUBOT_GRAFANA_S3_ACCESS_KEY_ID=ABCDEF123456XYZ |
||||
export HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY=aBcD01234dEaDbEef01234 |
||||
export HUBOT_GRAFANA_S3_PREFIX=graphs |
||||
export HUBOT_GRAFANA_S3_REGION=us-standard |
||||
``` |
||||
|
||||
### Grafana server side rendering |
||||
|
||||
The hubot plugin will take advantage of the Grafana server side rendering feature that can |
||||
render any panel on the server using phantomjs. Grafana ships with a phantomjs binary (Linux only). |
||||
|
||||
To verify that this feature works try the `Direct link to rendered image` link in the panel share dialog. |
||||
If you do not get an image when opening this link verify that the required font packages are installed for phantomjs to work. |
||||
|
||||
### Grafana API Key |
||||
|
||||
{{< docs-imagebox img="/img/docs/v2/orgdropdown_api_keys.png" max-width="150px" class="docs-image--right">}} |
||||
|
||||
You need to set the environment variable `HUBOT_GRAFANA_API_KEY` to a Grafana API Key. |
||||
You can add these from the API Keys page which you find in the Organization dropdown. |
||||
|
||||
### Amazon S3 |
||||
|
||||
The `S3` options are optional but for the images to work properly in services like Slack and Hipchat they need |
||||
to publicly available. By specifying the `S3` options the hubot-grafana script will publish the rendered |
||||
panel to `S3` and it will use that URL when it posts to Slack or Hipchat. |
||||
|
||||
## Hubot commands |
||||
|
||||
- `hubot graf list` |
||||
- Lists the available dashboards |
||||
- `hubot graf db graphite-carbon-metrics` |
||||
- Graph all panels in the dashboard |
||||
- `hubot graf db graphite-carbon-metrics:3` |
||||
- Graph only panel with id 3 of a particular dashboard |
||||
- `hubot graf db graphite-carbon-metrics:cpu` |
||||
- Graph only the panels containing "cpu" (case insensitive) in the title |
||||
- `hubot graf db graphite-carbon-metrics now-12hr` |
||||
- Get a dashboard with a window of 12 hours ago to now |
||||
- `hubot graf db graphite-carbon-metrics now-24hr now-12hr` |
||||
- Get a dashboard with a window of 24 hours ago to 12 hours ago |
||||
- `hubot graf db graphite-carbon-metrics:3 now-8d now-1d` |
||||
- Get only the third panel of a particular dashboard with a window of 8 days ago to yesterday |
||||
- `hubot graf db graphite-carbon-metrics host=carbon-a` |
||||
- Get a templated dashboard with the `$host` parameter set to `carbon-a` |
||||
|
||||
## Aliases |
||||
|
||||
Some of the hubot commands above can lengthy and you might have to remember the dashboard slug (url id). |
||||
If you have a few favorite graphs you want to be able check up on often (let's say from your mobile) you |
||||
can create hubot command aliases with the hubot script `hubot-alias`. |
||||
|
||||
Install it: |
||||
|
||||
```bash |
||||
npm i --save hubot-alias |
||||
``` |
||||
|
||||
Now add `hubot-alias` to the list of plugins in `external-scripts.json` and restart hubot. |
||||
|
||||
Now you can add an alias like this: |
||||
|
||||
- `hubot alias graf-lb=graf db loadbalancers:2 now-20m` |
||||
|
||||
<div class="text-center"> |
||||
Using the alias:<br> |
||||
<img src="/img/docs/tutorials/hubot_grafana2.png" class="center"></a> |
||||
</div> |
||||
|
||||
## Summary |
||||
|
||||
Grafana is going to ship with integrated Slack and Hipchat features some day but you do |
||||
not have to wait for that. Grafana 2 shipped with a very clever server side rendering feature |
||||
that can render any panel to a png using phantomjs. The hubot plugin for Grafana is something |
||||
you can install and use today! |
||||
|
||||
|
||||
@ -1,89 +0,0 @@ |
||||
+++ |
||||
title = "Grafana with IIS Reverse Proxy on Windows" |
||||
type = "docs" |
||||
keywords = ["grafana", "tutorials", "proxy", "IIS", "windows"] |
||||
[menu.docs] |
||||
parent = "tutorials" |
||||
weight = 10 |
||||
+++ |
||||
|
||||
# How to Use IIS with URL Rewrite as a Reverse Proxy for Grafana on Windows |
||||
|
||||
If you want Grafana to be a subpath or subfolder under a website in IIS then the URL Rewrite module for ISS can be used to support this. |
||||
|
||||
Example: |
||||
|
||||
- Parent site: http://localhost:8080 |
||||
- Grafana: http://localhost:3000 |
||||
|
||||
Grafana as a subpath: http://localhost:8080/grafana |
||||
|
||||
## Setup |
||||
|
||||
If you have not already done it, then a requirement is to install URL Rewrite module for IIS. |
||||
|
||||
Download and install the URL Rewrite module for IIS: https://www.iis.net/downloads/microsoft/url-rewrite |
||||
|
||||
## Grafana Config |
||||
|
||||
The Grafana config can be set by creating a file named `custom.ini` in the `conf` subdirectory of your Grafana installation. See the [installation instructions](http://docs.grafana.org/installation/windows/#configure) for more details. |
||||
|
||||
Given that the subpath should be `grafana` and the parent site is `localhost:8080` then add this to the `custom.ini` config file: |
||||
|
||||
```bash |
||||
[server] |
||||
domain = localhost:8080 |
||||
root_url = %(protocol)s://%(domain)s/grafana/ |
||||
``` |
||||
|
||||
Restart the Grafana server after changing the config file. |
||||
|
||||
## IIS Config |
||||
|
||||
1. Open the IIS Manager and click on the parent website |
||||
2. In the admin console for this website, double click on the URL Rewrite option: |
||||
{{< docs-imagebox img="/img/docs/tutorials/IIS_admin_console.png" max-width= "800px" >}} |
||||
|
||||
3. Click on the `Add Rule(s)...` action |
||||
4. Choose the Blank Rule template for an Inbound Rule |
||||
{{< docs-imagebox img="/img/docs/tutorials/IIS_add_inbound_rule.png" max-width= "800px" >}} |
||||
|
||||
5. Create an Inbound Rule for the parent website (localhost:8080 in this example) with the following settings: |
||||
- pattern: `grafana(/)?(.*)` |
||||
- check the `Ignore case` checkbox |
||||
- rewrite URL set to `http://localhost:3000/{R:2}` |
||||
- check the `Append query string` checkbox |
||||
- check the `Stop processing of subsequent rules` checkbox |
||||
|
||||
{{< docs-imagebox img="/img/docs/tutorials/IIS_url_rewrite.png" max-width= "800px" >}} |
||||
|
||||
Finally, navigate to `http://localhost:8080/grafana` (replace `http://localhost:8080` with your parent domain) and you should come to the Grafana login page. |
||||
|
||||
## Troubleshooting |
||||
|
||||
### 404 error |
||||
|
||||
When navigating to the Grafana URL (`http://localhost:8080/grafana` in the example above) and a `HTTP Error 404.0 - Not Found` error is returned then either: |
||||
|
||||
- the pattern for the Inbound Rule is incorrect. Edit the rule, click on the `Test pattern...` button, test the part of the URL after `http://localhost:8080/` and make sure it matches. For `grafana/login` the test should return 3 capture groups: {R:0}: `grafana` {R:1}: `/` and {R:2}: `login`. |
||||
- The `root_url` setting in the Grafana config file does not match the parent URL with subpath. |
||||
|
||||
### Grafana Website only shows text with no images or css |
||||
|
||||
{{< docs-imagebox img="/img/docs/tutorials/IIS_proxy_error.png" max-width= "800px" >}} |
||||
|
||||
1. The `root_url` setting in the Grafana config file does not match the parent URL with subpath. This could happen if the root_url is commented out by mistake (`;` is used for commenting out a line in .ini files): |
||||
|
||||
`; root_url = %(protocol)s://%(domain)s/grafana/` |
||||
|
||||
2. or if the subpath in the `root_url` setting does not match the subpath used in the pattern in the Inbound Rule in IIS: |
||||
|
||||
`root_url = %(protocol)s://%(domain)s/grafana/` |
||||
|
||||
pattern in Inbound Rule: `wrongsubpath(/)?(.*)` |
||||
|
||||
3. or if the Rewrite URL in the Inbound Rule is incorrect. |
||||
|
||||
The Rewrite URL should not include the subpath. |
||||
|
||||
The Rewrite URL should contain the capture group from the pattern matching that returns the part of the URL after the subpath. The pattern used above returns 3 capture groups and the third one {R:2} returns the part of the URL after `http://localhost:8080/grafana/`. |
||||
Loading…
Reference in new issue