Skip to content

Commit

Permalink
Fix InfluxDB output mode and add CI for it
Browse files Browse the repository at this point in the history
- Use a backslash to escape the space after the tags
- Add a simple Telegraf config that reproduces syntax errors

See: https://progress.opensuse.org/issues/121582
  • Loading branch information
kalikiana committed Mar 10, 2023
1 parent 03e81c6 commit 747d899
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: pytest -vv
- name: Install Telegraf
run: sudo apt-get install -y telegraf
- name: Test InfluxDB output
run: telegraf --test --config slo.conf
4 changes: 2 additions & 2 deletions backlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ def render_influxdb(data):
count = len(result[status]["leadTime"])
if status == "Resolved":
measure = "leadTime"
extra = " leadTime={leadTime} cycleTime={cycleTime}".format(
extra = ",leadTime={leadTime},cycleTime={cycleTime}".format(
leadTime=mean(result[status]["leadTime"]),
cycleTime=mean(result[status]["cycleTime"]),
)
else:
measure = "slo"
extra = ""
output.append(
'{measure},team="{team}",status="{status}",title="{title}" count={count}{extra}'.format(
'{measure},team="{team}",status="{status}",title="{title}"\\ count={count}{extra}'.format(
measure=measure,
team=data["team"],
status=status,
Expand Down
5 changes: 5 additions & 0 deletions slo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[inputs.exec]]
commands = [ "env REDMINE_API_KEY=abcdefgah0123456789 ./backlogger.py --output=influxdb" ]
interval = "1h"
timeout = "10s"
data_format = "influx"
4 changes: 2 additions & 2 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_influxdb(self):
self.assertEqual(
backlogger.render_influxdb(data),
[
'slo,team="Awesome Team",status="In Progress",title="Workable Backlog" count=2',
'leadTime,team="Awesome Team",status="Resolved",title="Workable Backlog" count=1 leadTime=383.2547222222222 cycleTime=48.0',
'slo,team="Awesome Team",status="In Progress",title="Workable Backlog"\\ count=2',
'leadTime,team="Awesome Team",status="Resolved",title="Workable Backlog"\\ count=1,leadTime=383.2547222222222,cycleTime=48.0',
],
)

0 comments on commit 747d899

Please sign in to comment.