Populating InfluxDB with individual tags and fields from JSON message
See original GitHub issueBeen playing with fail2ban over the past couple of days…and from it managed to get a json formatted mqtt message out on each ban.
{ "ip": "37.49.226.155", "failures": "28", "jail": "ssh", "time": "1591645309.58". "country": "<country"> }
So now I want to get these into influx.
Here is my section…I’ve tried all sorts of combinations. I basically want a table, with tags for the jail (ssh) and ip, with values of the number of failures.
; -----------------------------------------
; Fail2ban
; -----------------------------------------
[fail2ban/ban]
#topic = fail2ban/ban
targets = influxdb:fail2ban
format = jail={jail},ip={ip} value={failures}
But nothing I do seems to affect the format. The logs just try sending the entire json string as the value:
2020-06-09 07:41:50,985 DEBUG [connectionpool] http://influxdb:8096 "POST /write?db=network&rp=default&precision=ns HTTP/1.1" 400 219
2020-06-09 07:41:50,987 WARNING [influxdb] POST request failed: (400) {"error":"unable to parse 'fail2ban,topic=fail2ban_ban value={ \"ip\": \"37.49.226.155\", \"failures\": \"28\", \"jail\": \"ssh\", \"time\": \"1591645309.58\". \"country\": \"\u003ccountry\"\u003e }': invalid boolean"}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Convert results to JSON and send them to a URL | InfluxDB ...
Use json.encode() to convert query results to JSON and http.post() to send them to a URL endpoint.
Read more >JSON to InfluxDB Line Protocol Using Telegraf and Starlark
This video shows how to convert nested JSON into InfluxDB line protocol, using the Telegraf Starklark processor. You'll be able to take ...
Read more >Getting MQTT Data into InfluxDB - Full Stack Energy
Forwarding Data to InfluxDB via MQTT and Telegraf. ... I have deployed in various fields, sometimes literally, is having them populate our ...
Read more >Only last stage data is sent to influx db from jenkins pipeline
durationMillis myDataField1['stage_name'] = jsonObject.stages[i].name //populating the tag type columns of InfluxDB measurements and pushing ...
Read more >InfluxDB 2 Sink Connector for Confluent Cloud Quick Start
If you plan to use one or more Single Message Transforms (SMTs), ... It can contain a number of InfluxdDB fields, a tag...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this can be closed now also, as I’m running main mqttwarn and not a custom one.
So I pulled the latest influxdb code (was able to add it as a quick local service). With this config and the change found by @jacques42:
And json of :
I’m now getting entries into a fail2ban table with
Which is good enough for me. Unbans go into the same table. with fail2ban_unban. Ideally I’d like it just to say ban an unban, but close enough.
I should merge you latest code into my branch for updates. Since my PR would be well out of date now. (#375)