From db8be35ce5afe90878981287bc8d0b4c513eb3e8 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sun, 30 Oct 2016 18:44:46 +0300 Subject: [PATCH 1/5] Docs: added templating guide. --- docs/mkdocs.yml | 1 + docs/sources/guides/templating.md | 75 +++++++++++++++++++ docs/sources/img/templating-menu.png | 3 + .../img/templating-query_with_variables.png | 3 + .../img/templating-variable_editor.png | 3 + 5 files changed, 85 insertions(+) create mode 100644 docs/sources/guides/templating.md create mode 100644 docs/sources/img/templating-menu.png create mode 100644 docs/sources/img/templating-query_with_variables.png create mode 100644 docs/sources/img/templating-variable_editor.png diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 8446da5..290a1de 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -19,6 +19,7 @@ pages: - 'Troubleshooting': 'installation/troubleshooting.md' - User Guides: - 'Getting Started': 'guides/gettingstarted.md' + - 'Templating': 'guides/templating.md' - Reference: - 'Zabbix Datasource': 'reference/datasource-zabbix.md' - 'Triggers Panel': 'reference/panel-triggers.md' diff --git a/docs/sources/guides/templating.md b/docs/sources/guides/templating.md new file mode 100644 index 0000000..28b12fd --- /dev/null +++ b/docs/sources/guides/templating.md @@ -0,0 +1,75 @@ +# Templating Guide +You can use template variables for creating highly reusable and interactive dashboards. General idea of templating is allow Grafana to get different metrics from data source and provide a way to change it on the fly without modifying dashboard. In case of Zabbix it means that you can get list of Host Groups, Hosts, Applications or Items and add it as a variables. + +## Creating Variable +To create template variable click the cog icon on the top navigation bar and choose _Templating_. + +![Templating menu](../img/templating-menu.png) + +When you click _New_ button, you'll see template variable editor. It contains these sections: + +![Variable editor](../img/templating-variable_editor.png) + +### Variable + +**Name** +Name of the variable. You should use this name in queries. + +**Label** +Visible label for variable. Use when you want to display different name on dashboard. For instance, _Host Group_ instead *host_group*. + +**Type** +By default _Query_ type is selected. It means that Grafana asks data source for values of variable. But there are some other types: _Interval_ (just a time interval), _Data source_ (You can switch data source, for example, if you have more than one Zabbix instance and each added into Grafana as data source), _Custom_ (you can set any predefined values for variable) and _Constant_. + +### Query Options + +**Data source** +Data source used for querying variable values. + +**Refresh** +When to update the values of this variable. + +**Query** +Query string. + +**Regex** +Use regex if you need to filter values or extract a part of value. + +### Selection Options + +**Multi-value** +Enable, if you want to select multiple values at the same time. + +### Value groups/tags (Experimental feature) + +## Query Format +Template variable query in Zabbix data source is a string which contains 4 parts divided by period (`.`): +``` +{host group}.{host}.{application}.{item name} +``` +For example, `Zabbix servers.Zabbix server.CPU.*` + +Each part can be a name of corresponding metric or `*`, which means _all metrics_. + +Examples: + + - `*` returns list of all available Host Groups + - `*.*` all hosts in Zabbix + - `Network.*` returns all hosts in group Network + - `Linux servers.*.*` returns all applications from hosts in Linux servers group + - `Linux servers.backend01.CPU.*` returns all items from backend01 belonging to CPU application. + +You can use another variable as a part of query. For instance, you have variable _group_, which returns list of host groups and want to use it for querying hosts in selected group only. Here's a query for this case: +``` +$group.* +``` + +## Variables Usage + +When you create a variable, you can use it as a part of data source query. Grafana also supports variables in different places like panel's and row's titles, Text panel's content, etc. + +![Query with variables](../img/templating-query_with_variables.png) + +> Note, that you should add `$` sign before variable's name (**$host** for _host_ variable). + +See more about templating in [Grafana docs](http://docs.grafana.org/reference/templating) diff --git a/docs/sources/img/templating-menu.png b/docs/sources/img/templating-menu.png new file mode 100644 index 0000000..4b547e7 --- /dev/null +++ b/docs/sources/img/templating-menu.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8ac9a48403b9ad670c3739e81292ff247cd105016695d1dcc8b5fd5e3325c00 +size 87143 diff --git a/docs/sources/img/templating-query_with_variables.png b/docs/sources/img/templating-query_with_variables.png new file mode 100644 index 0000000..9594a33 --- /dev/null +++ b/docs/sources/img/templating-query_with_variables.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7946b4eb820f5256e8aadf053b55e4a2061619888f2283516cf78b09ab179a83 +size 513234 diff --git a/docs/sources/img/templating-variable_editor.png b/docs/sources/img/templating-variable_editor.png new file mode 100644 index 0000000..003ba81 --- /dev/null +++ b/docs/sources/img/templating-variable_editor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ceea183bd12e5b28161f75c40df2530069831a8a8db12b4484a76fb1f88e8e9 +size 641375 From f14f608c5a9afb6905bfc5081fc18d9c1b05d45e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sun, 30 Oct 2016 21:02:21 +0300 Subject: [PATCH 2/5] Customizing docs styles. --- docs/mkdocs.yml | 2 ++ docs/sources/css/custom.css | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/sources/css/custom.css diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 290a1de..419310b 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -7,6 +7,8 @@ copyright: Copyright © 2015-2016, Alexander Zobnin docs_dir: sources theme: readthedocs +extra_css: + - css/custom.css pages: - Project: diff --git a/docs/sources/css/custom.css b/docs/sources/css/custom.css new file mode 100644 index 0000000..99a6b92 --- /dev/null +++ b/docs/sources/css/custom.css @@ -0,0 +1,37 @@ +.wy-side-nav-search { + background-color: #8e3030 +} + +p { + margin-bottom: 24px; +} + +.rst-content blockquote { + margin-left: 0px; + padding: 0 1em; + color: #777; + border-left: 0.25em solid #ddd; +} + +code, .rst-content tt { + font-size: 85%; + color: #404040; + background-color: #f4f4f4; + padding: 1px 5px; + border-radius: 2px; +} + +.hljs { + font-size: 100%; + padding: 1em 0.5em; + border-radius: 4px; + border-color: #f4f4f4; +} + +.btn-neutral:hover { + background-color: #8e3030 !important; + color: #f4f4f4 !important; + box-shadow: + 0px 1px 2px -1px rgba(255,255,255,0.5) inset, + 0px -2px 0px 0px rgba(0, 0, 0, 0.2) inset; +} \ No newline at end of file From bd786e7b8a1fe47754db9c403f6ce5100f8ab3d7 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sun, 30 Oct 2016 22:01:55 +0300 Subject: [PATCH 3/5] Fix line height in code block. --- docs/sources/css/custom.css | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sources/css/custom.css b/docs/sources/css/custom.css index 99a6b92..8762c9b 100644 --- a/docs/sources/css/custom.css +++ b/docs/sources/css/custom.css @@ -23,6 +23,7 @@ code, .rst-content tt { .hljs { font-size: 100%; + line-height: 1.5; padding: 1em 0.5em; border-radius: 4px; border-color: #f4f4f4; From 9f70be1dcf2a1c516a40b3aae6a38f9d8b39c8db Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 16 Nov 2016 23:21:05 +0300 Subject: [PATCH 4/5] Fixed navbar color in mobile layout. --- docs/sources/css/custom.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/css/custom.css b/docs/sources/css/custom.css index 8762c9b..2c163b3 100644 --- a/docs/sources/css/custom.css +++ b/docs/sources/css/custom.css @@ -1,4 +1,4 @@ -.wy-side-nav-search { +.wy-side-nav-search, .wy-nav-top { background-color: #8e3030 } From 8badc378645bcb88b4264a2e2f11497b0c687560 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 17 Nov 2016 16:04:11 +0300 Subject: [PATCH 5/5] Added edit_uri to mkdocs conf for future usage. --- docs/mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 419310b..d966f1f 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -3,6 +3,7 @@ site_name: Grafana-Zabbix Documentation #site_url: / site_description: Documentation for Grafana-Zabbix, Zabbix monitoring system plugin bundle for Grafana repo_url: https://github.com/alexanderzobnin/grafana-zabbix/ +edit_uri: blob/master/docs/sources/ copyright: Copyright © 2015-2016, Alexander Zobnin docs_dir: sources