From fc76530577a461eed94f875312388b15e14eedb4 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Tue, 24 Oct 2017 15:13:04 +0200 Subject: [PATCH] docs: document annotations for postgres/mysql --- docs/sources/features/datasources/index.md | 3 ++- docs/sources/features/datasources/influxdb.md | 4 +-- docs/sources/features/datasources/mysql.md | 25 +++++++++++++++++-- docs/sources/features/datasources/postgres.md | 23 +++++++++++++++++ docs/sources/reference/annotations.md | 4 +-- 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/docs/sources/features/datasources/index.md b/docs/sources/features/datasources/index.md index 56501980c31..54606d20988 100644 --- a/docs/sources/features/datasources/index.md +++ b/docs/sources/features/datasources/index.md @@ -28,8 +28,9 @@ The following datasources are officially supported: * [InfluxDB]({{< relref "influxdb.md" >}}) * [OpenTSDB]({{< relref "opentsdb.md" >}}) * [Prometheus]({{< relref "prometheus.md" >}}) +* [MySQL]({{< relref "mysql.md" >}}) +* [Postgres]({{< relref "postgres.md" >}}) ## Data source plugins Since grafana 3.0 you can install data sources as plugins. Checkout [Grafana.net](https://grafana.com/plugins) for more data sources. - diff --git a/docs/sources/features/datasources/influxdb.md b/docs/sources/features/datasources/influxdb.md index 97e523cd151..6d0918a0d01 100644 --- a/docs/sources/features/datasources/influxdb.md +++ b/docs/sources/features/datasources/influxdb.md @@ -173,6 +173,4 @@ SELECT title, description from events WHERE $timeFilter order asc For InfluxDB you need to enter a query like in the above example. You need to have the ```where $timeFilter``` part. If you only select one column you will not need to enter anything in the column mapping fields. The -Tags field can be a comma seperated string. - - +Tags field can be a comma separated string. diff --git a/docs/sources/features/datasources/mysql.md b/docs/sources/features/datasources/mysql.md index f67ab5f3f13..69c6f667062 100644 --- a/docs/sources/features/datasources/mysql.md +++ b/docs/sources/features/datasources/mysql.md @@ -174,7 +174,28 @@ WHERE $__timeFilter(atimestamp) and hostname in([[hostname]]) ORDER BY atimestamp ASC ``` +## Annotations + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. + +An example query: + +```sql +SELECT + UNIX_TIMESTAMP(atimestamp) as time_sec, + value as text, + CONCAT(tag1, ',', tag2) as tags +FROM my_table +WHERE $__timeFilter(atimestamp) +ORDER BY atimestamp ASC +``` + +Name | Description +------------ | ------------- +time_sec | The name of the date/time field. +text | Event description field. +tags | Optional field name to use for event tags as a comma separated string. + ## Alerting -Time series queries should work in alerting conditions. Table formatted queries is not yet supported in alert rule -conditions. +Time series queries should work in alerting conditions. Table formatted queries is not yet supported in alert rule conditions. diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index d9239b923ba..154f822d9d0 100644 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -184,6 +184,29 @@ WHERE $__timeFilter(atimestamp) and hostname in([[hostname]]) ORDER BY atimestamp ASC ``` +## Annotations + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. + +An example query: + +```sql +SELECT + extract(epoch from time_date_time) AS time, + metric1 as text, + concat_ws(', ', metric1::text, metric2::text) as tags +FROM + public.test_data +WHERE + $__timeFilter(time_date_time) +``` + +Name | Description +------------ | ------------- +time | The name of the date/time field. +text | Event description field. +tags | Optional field name to use for event tags as a comma separated string. + ## Alerting Time series queries should work in alerting conditions. Table formatted queries is not yet supported in alert rule diff --git a/docs/sources/reference/annotations.md b/docs/sources/reference/annotations.md index 3852c2c727b..de118f37d46 100644 --- a/docs/sources/reference/annotations.md +++ b/docs/sources/reference/annotations.md @@ -69,5 +69,5 @@ The annotation query options are different for each data source. - [Elasticsearch annotation queries]({{< relref "features/datasources/elasticsearch.md#annotations" >}}) - [InfluxDB annotation queries]({{< relref "features/datasources/influxdb.md#annotations" >}}) - [Prometheus annotation queries]({{< relref "features/datasources/prometheus.md#annotations" >}}) - - +- [MySQL annotation queries]({{< relref "features/datasources/mysql.md#annotations" >}}) +- [Postgres annotation queries]({{< relref "features/datasources/postgres.md#annotations" >}})