update to 1.13.4; create directory /etc/telegraf/telegraf.d/ OBS-URL: https://build.opensuse.org/request/show/781648 OBS-URL: https://build.opensuse.org/package/show/devel:languages:go/telegraf?expand=0&rev=22
95 lines
3.3 KiB
Diff
95 lines
3.3 KiB
Diff
From 0b3ff433caa76cd644819cab50301f9a2a5b01a1 Mon Sep 17 00:00:00 2001
|
|
From: Johannes Kastl <kastl@b1-systems.de>
|
|
Date: Wed, 26 Feb 2020 16:38:01 +0100
|
|
Subject: [PATCH] plugins/outputs/sql/README.md: Generic SQL output plugin for
|
|
Telegraf (patch taken from openSUSE RPM package of telegraf 1.12.6)
|
|
|
|
Signed-off-by: Johannes Kastl <kastl@b1-systems.de>
|
|
---
|
|
plugins/outputs/sql/README.md | 73 +++++++++++++++++++++++++++++++++++
|
|
1 file changed, 73 insertions(+)
|
|
create mode 100644 plugins/outputs/sql/README.md
|
|
|
|
diff --git a/plugins/outputs/sql/README.md b/plugins/outputs/sql/README.md
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..2d29af83fdcc5afc69d2d38002e02ae852223f8f
|
|
--- /dev/null
|
|
+++ b/plugins/outputs/sql/README.md
|
|
@@ -0,0 +1,73 @@
|
|
+# SQL plugin
|
|
+
|
|
+The plugin inserts values to SQL various database.
|
|
+Supported/integrated drivers are mssql (SQLServer), mysql (MySQL), postgres (Postgres)
|
|
+Activable drivers (read below) are all golang SQL compliant drivers (see https://github.com/golang/go/wiki/SQLDrivers): for instance oci8 for Oracle or sqlite3 (SQLite)
|
|
+
|
|
+## Getting started :
|
|
+First you need to grant insert (if auto create table create) privileges to the database user you use for the connection
|
|
+
|
|
+## Configuration:
|
|
+
|
|
+```
|
|
+# Send metrics to SQL-Database (Example configuration for MySQL/MariaDB)
|
|
+[[outputs.sql]]
|
|
+ ## Database Driver, required.
|
|
+ ## Valid options: mssql (SQLServer), mysql (MySQL), postgres (Postgres), sqlite3 (SQLite), [oci8 ora.v4 (Oracle)]
|
|
+ driver = "mysql"
|
|
+
|
|
+ ## specify address via a url matching:
|
|
+ ## postgres://[pqgotest[:password]]@localhost[/dbname]\
|
|
+ ## ?sslmode=[disable|verify-ca|verify-full]
|
|
+ ## or a simple string:
|
|
+ ## host=localhost user=pqotest password=... sslmode=... dbname=app_production
|
|
+ ##
|
|
+ ## All connection parameters are optional.
|
|
+ ##
|
|
+ ## Without the dbname parameter, the driver will default to a database
|
|
+ ## with the same name as the user. This dbname is just for instantiating a
|
|
+ ## connection with the server and doesn't restrict the databases we are trying
|
|
+ ## to grab metrics for.
|
|
+ ##
|
|
+ address = "username:password@tcp(server:port)/table"
|
|
+
|
|
+ ## Available Variables:
|
|
+ ## {TABLE} - tablename as identifier
|
|
+ ## {TABLELITERAL} - tablename as string literal
|
|
+ ## {COLUMNS} - column definitions
|
|
+ ## {KEY_COLUMNS} - comma-separated list of key columns (time + tags)
|
|
+ ##
|
|
+
|
|
+ ## Check with this is table exists
|
|
+ ##
|
|
+ ## Template for MySQL is "SELECT 1 FROM {TABLE} LIMIT 1"
|
|
+ ##
|
|
+ table_exists_template = "SELECT 1 FROM {TABLE} LIMIT 1"
|
|
+
|
|
+ ## Template to use for generating tables
|
|
+
|
|
+ ## Default template
|
|
+ ##
|
|
+ # table_template = "CREATE TABLE {TABLE}({COLUMNS})"
|
|
+
|
|
+ ## Convert Telegraf datatypes to these types
|
|
+ [[outputs.sql.convert]]
|
|
+ integer = "INT"
|
|
+ real = "DOUBLE"
|
|
+ text = "TEXT"
|
|
+ timestamp = "TIMESTAMP"
|
|
+ defaultvalue = "TEXT"
|
|
+ unsigned = "UNSIGNED"
|
|
+```
|
|
+sql_script is read only once, if you change the script you need to reload telegraf
|
|
+
|
|
+## Field names
|
|
+If database table is not pre-created tries driver to create database. There can be errors as
|
|
+SQL has strict scheming.
|
|
+
|
|
+## Tested Databases
|
|
+Actually I run the plugin using MySQL
|
|
+
|
|
+## TODO
|
|
+1) Test with other databases
|
|
+2) More sane testing
|
|
--
|
|
2.25.1
|
|
|