@@ -2,46 +2,104 @@ Kafka-InfluxDB
2
2
==============
3
3
4
4
A Kafka consumer for InfluxDB written in Python.
5
- All messages sent to Kafka on a certain topic will be relayed to Influxdb.
6
- Supports Influxdb 0.8.x and 0.9.x .
5
+ All messages sent to Kafka on a certain topic will be relayed to Influxdb.
6
+ Supports InfluxDB 0.9.x. For InfluxDB 0.8 support look check out the 0.3.0 tag .
7
7
8
8
## Usage
9
9
10
- To run a simple test, you can provide config flags on the commandline like so:
10
+ ### Manual installation
11
11
12
- python kafka_influxdb.py --influxdb_host 127.0.0.1 --influxdb_port 8086
12
+ If you want to run a local instance, you can do so with the following commands:
13
13
14
- You can also specify a config file which is more convenient for running as a daemon:
14
+ pip install -r requirements.txt
15
+ # You might need to adjust the config.yaml
16
+ python kafka_influxdb.py -c config.yaml
15
17
16
- python kafka_influxdb.py --configfile my_config.yaml
18
+ ### Starting inside a container
19
+
20
+ The most convenient way to get started is running this inside a Docker container like so:
21
+
22
+ docker build -t mre/kafka_influxdb .
23
+ docker run -it --rm mre/kafka_influxdb
24
+
25
+ To run a simple test setup, you can run a collectd -> kafka -> kafka_influxdb -> influxdb toolchain with the following command:
26
+
27
+ docker-compose up
28
+
29
+ ## Supported input and output formats
30
+
31
+ ### Input formats
32
+
33
+ * Collectd Graphite, e.g. "mydatacenter.myhost.load.load.shortterm 0.45 1436357630"
34
+
35
+ ### Output formats
36
+
37
+ * InfluxDB 0.9 line protocol output (e.g. ` load_load_shortterm,datacenter=mydatacenter,host=myhost value="0.45" 1436357630 ` )
38
+ * InfluxDB 0.8 JSON output (deprecated)
39
+
40
+ ### Extending
41
+
42
+ You can write a custom encoder to support any other format (even fancy things like Protobuf).
43
+ Look at the examples in the ` encoder ` folder to get started.
17
44
18
45
## Configuration
19
46
20
- kafka_influxdb.py [-h] [--kafka_host KAFKA_HOST]
21
- [--kafka_port KAFKA_PORT]
22
- [--kafka_topic KAFKA_TOPIC]
23
- [--kafka_group KAFKA_GROUP]
24
- [--influxdb_host INFLUXDB_HOST]
25
- [--influxdb_port INFLUXDB_PORT]
26
- [--influxdb_user INFLUXDB_USER]
27
- [--influxdb_password INFLUXDB_PASSWORD]
28
- [--influxdb_dbname INFLUXDB_DBNAME]
29
- [--influxdb_data_name INFLUXDB_DATA_NAME]
30
- [--influxdb_columns INFLUXDB_COLUMNS]
31
- [--influxdb_version DB_VERSION]
32
- [--influxdb_retention_policy RETENTION_POLICY]
33
- [--buffer_size BUFFER_SIZE]
34
- [--verbose BOOLEAN]
35
- [--statistics BOOLEAN]
36
- [--configfile CONFIG_FILE]
47
+ usage: kafka_influxdb.py [ -h] [ --kafka_host KAFKA_HOST]
48
+ [ --kafka_port KAFKA_PORT] [ --kafka_topic KAFKA_TOPIC]
49
+ [ --kafka_group KAFKA_GROUP]
50
+ [ --influxdb_host INFLUXDB_HOST]
51
+ [ --influxdb_port INFLUXDB_PORT]
52
+ [ --influxdb_user INFLUXDB_USER]
53
+ [ --influxdb_password INFLUXDB_PASSWORD]
54
+ [ --influxdb_dbname INFLUXDB_DBNAME]
55
+ [ --influxdb_retention_policy INFLUXDB_RETENTION_POLICY]
56
+ [ --influxdb_time_precision INFLUXDB_TIME_PRECISION]
57
+ [ --encoder ENCODER] [ --buffer_size BUFFER_SIZE]
58
+ [ -c CONFIGFILE] [ -v]
37
59
38
- Command line settings have precedence over config file provided settings. See the sample at ` config.yaml ` to get an idea on the format.
60
+ A Kafka consumer for InfluxDB
61
+
62
+ optional arguments:
63
+ -h, --help show this help message and exit
64
+ --kafka_host KAFKA_HOST
65
+ Hostname or IP of Kafka message broker (default:
66
+ localhost)
67
+ --kafka_port KAFKA_PORT
68
+ Port of Kafka message broker (default: 9092)
69
+ --kafka_topic KAFKA_TOPIC
70
+ Topic for metrics (default: test)
71
+ --kafka_group KAFKA_GROUP
72
+ Kafka consumer group (default: my_group)
73
+ --influxdb_host INFLUXDB_HOST
74
+ InfluxDB hostname or IP (default: localhost)
75
+ --influxdb_port INFLUXDB_PORT
76
+ InfluxDB API port (default: 8086)
77
+ --influxdb_user INFLUXDB_USER
78
+ InfluxDB username (default: root)
79
+ --influxdb_password INFLUXDB_PASSWORD
80
+ InfluxDB password (default: root)
81
+ --influxdb_dbname INFLUXDB_DBNAME
82
+ InfluXDB database to write metrics into (default:
83
+ metrics)
84
+ --influxdb_retention_policy INFLUXDB_RETENTION_POLICY
85
+ Retention policy for incoming metrics (default:
86
+ default)
87
+ --influxdb_time_precision INFLUXDB_TIME_PRECISION
88
+ Precision of incoming metrics. Can be one of 's', 'm',
89
+ 'ms', 'u' (default: s)
90
+ --encoder ENCODER Input encoder which converts an incoming message to
91
+ dictionary (default: collectd_graphite_encoder)
92
+ --buffer_size BUFFER_SIZE
93
+ Maximum number of messages that will be collected
94
+ before flushing to the backend (default: 1000)
95
+ -c CONFIGFILE, --configfile CONFIGFILE
96
+ Configfile path (default: None)
97
+ -v, --verbose Show info and debug messages while running (default:
98
+ False)
39
99
40
- ## Dependencies
100
+ Command line settings have precedence over config file provided settings. See the sample at ` config.yaml ` to get an idea on the format.
41
101
42
- Please note that you must install the version of the influxdb python client matching your influxdb version (for 0.9 see https://github.com/influxdb/influxdb-python/tree/0.9.0_support )
102
+ ## TODO
43
103
44
- ## Todo
45
104
* flush buffer if not full but some period has elapsed (safety net for low frequency input)
46
- * offset management, if not already supported in kafka client
47
- * create error log
105
+ * Provide environment variables for docker
0 commit comments