From 18ebfa31bc6dcb58a7120c9d6f29952d0cc8c709 Mon Sep 17 00:00:00 2001 From: Dylan Redding Date: Tue, 24 May 2016 22:16:16 -0500 Subject: [PATCH 1/4] Updating for newer influxdb. --- requirements.txt | 2 +- send-annotation | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index afede28..490db63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ click==3.3 -influxdb==0.1.13 +influxdb==2.12.0 diff --git a/send-annotation b/send-annotation index 09373bc..3e2dd3d 100755 --- a/send-annotation +++ b/send-annotation @@ -23,9 +23,12 @@ def cli(db_host, db_port, db_name, user, password, title, tags, text): db = influxdb.InfluxDBClient(db_host, db_port, user, password, db_name) tags_field = str.join(';', tags) data = [{ - 'name': 'events', - 'columns': ['tags', 'text', 'title'], - 'points': [[tags_field, text, title]] + 'measurement': 'events', + 'fields': { + 'tags': tags_field, + 'title': title, + 'text': text + } }] db.write_points(data) except Exception as e: From 81ce1a3beaba91f7f90dcee40879763a09bb5ed2 Mon Sep 17 00:00:00 2001 From: Dylan Redding Date: Tue, 24 May 2016 22:38:57 -0500 Subject: [PATCH 2/4] Updated README and setup.py. --- README.rst | 2 ++ setup.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index a1df0a8..ad82fe7 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,8 @@ annotate-influxdb Grafana annotations provide a way to mark points on the graph with rich events. When you hover over an annotation you can get title, tags, and text information for the event. This utility is command line tool to send annotation into InfluxDB database. +This has been updated and tested to work with influxdb v0.12. If you are using influxdb that is older than v0.9, please use version 0.0.1. + Grafana configuration ===================== diff --git a/setup.py b/setup.py index 30b82e4..e077e6b 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ zip_safe=False, long_description='Write annotations (http://grafana.org/docs/features/annotations/) into InfluxDB', install_requires=[ - 'click==3.3', - 'influxdb==0.1.13', + 'click==6.6', + 'influxdb==2.12.0', ], ) From 29ce5dc2380c183fdc39500c35c990e245fbf467 Mon Sep 17 00:00:00 2001 From: Dylan Redding Date: Tue, 24 May 2016 22:40:58 -0500 Subject: [PATCH 3/4] Updated README again. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ad82fe7..4e0b31c 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ annotate-influxdb Grafana annotations provide a way to mark points on the graph with rich events. When you hover over an annotation you can get title, tags, and text information for the event. This utility is command line tool to send annotation into InfluxDB database. -This has been updated and tested to work with influxdb v0.12. If you are using influxdb that is older than v0.9, please use version 0.0.1. +This has been updated and tested to work with InfluxDB v0.12. If you are using InfluxDB that is older than v0.9, please use version 0.0.1. Grafana configuration ===================== From 739ee90217d950efe1b06a850da3b1e04593dc90 Mon Sep 17 00:00:00 2001 From: Dylan Redding Date: Tue, 24 May 2016 22:47:26 -0500 Subject: [PATCH 4/4] Added strip to remove newline char when echo is used. --- send-annotation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send-annotation b/send-annotation index 3e2dd3d..f0e478d 100755 --- a/send-annotation +++ b/send-annotation @@ -17,7 +17,7 @@ from influxdb import client as influxdb @click.option('-D', '--description', 'text', help='event description') def cli(db_host, db_port, db_name, user, password, title, tags, text): if text is None: - text = "\n".join([line for line in sys.stdin]) + text = "\n".join([line.rstrip('\n') for line in sys.stdin]) try: db = influxdb.InfluxDBClient(db_host, db_port, user, password, db_name)