Comments (5)
Dear @Sc0th,
thanks for your report. When talking about that this "worked for years", may I ask if you are by chance referring to a Python 2 installation of mqttwarn? That might give us some hints already about in which area something might have gone south.
Other than this, may I ask you to submit a full mqttwarn.ini configuration, and maybe a corresponding mosquitto_pub
command to be able to reproduce your scenario easily? This will tremendously help to discover and resolve the problem, hopefully quickly.
With kind regards,
Andreas.
from mqttwarn.
Hi @amotl
Thanks for getting back to me! I backed out to version 0.29.0 and all is well so suspect you are correct.
Requested details below:
config.ini
# -*- coding: utf-8 -*-
# (c) 2014-2018 The mqttwarn developers
#
# mqttwarn example configuration file "mqttwarn.ini"
#
; ------------------------------------------
; Base configuration
; ------------------------------------------
[defaults]
; ----
; MQTT
; ----
hostname = 'mqtt.<my domain>'
port = 1883
username = None
password = None
clientid = 'mqttwarn'
lwt = 'clients/mqttwarn'
skipretained = False
cleansession = False
# MQTTv31 = 3 (default)
# MQTTv311 = 4
protocol = 3
; -------
; Logging
; -------
; Send log output to STDERR
;logfile = 'stream://sys.stderr'
; Send log output to file
logfile = '/data/logs/mqttwarn.log'
; one of: CRITICAL, DEBUG, ERROR, INFO, WARN
loglevel = DEBUG
;logformat = '%(asctime)-15s %(levelname)-8s [%(name)-25s] %(message)s'
; --------
; Services
; --------
; path to file containing self-defined functions for formatmap and datamap
;functions = 'samplefuncs.py'
; name the service providers you will be using.
launch = file, http
directory = '/'
; -------
; Targets
; -------
;[config:file]
;append_newline = True
;targets = {
; 'all' : ['/data/logs/all.log'],
; }
[config:http]
targets = {
'graylog' : [ "post", "http://graylog.<my domain>:12201/gelf", None, None, None ]
}
[config:file]
append_newline = False
overwrite = True
targets = {
'changedetection' : ["/data/{topic}.dat"],
}
; ------------------------------------------
; Basic
; ------------------------------------------
[#]
#;targets = file:all, http:graylog
targets = http:graylog
template = graylog.json
[changedetect/#]
targets = file:changedetection
;template = changedetection.j2
mqtt publish:
mosquitto_pub -h mqtt -t scothnet/rack/racktemp -m 60
error in debug log:
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] Message received on scothnet/rack/racktemp: 60
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] Section [#] matches message on scothnet/rack/racktemp, processing it
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] Decoding JSON failed: 'int' object is not iterable. payload=60
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] Message on scothnet/rack/racktemp going to http:graylog
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] New `http:graylog' job: scothnet/rack/racktemp
2023-10-10 16:11:27,897 DEBUG [mqttwarn.core ] Processor #0 is handling: `http' for graylog
2023-10-10 16:11:27,898 ERROR [mqttwarn.core ] Rendering template failed: graylog.json
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/mqttwarn/core.py", line 526, in process_job
text = render_template(template, transform_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mqttwarn/core.py", line 99, in render_template
text = template.render(data)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "templates/graylog.json", line 17, in top-level template code
{{ data | jsonify }}
File "/usr/local/lib/python3.11/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
2023-10-10 16:11:27,898 INFO [mqttwarn.core ] Invoking service plugin for `http'
2023-10-10 16:11:27,898 DEBUG [mqttwarn.services.http ] *** MODULE=/usr/local/lib/python3.11/site-packages/mqttwarn/services/http_urllib.py: service
=http, target=graylog
2023-10-10 16:11:27,898 DEBUG [mqttwarn.services.http ] before send
2023-10-10 16:11:27,901 DEBUG [mqttwarn.core ] Job queue has 0 items to process
template (graylog.json):
{% set data = {
'version' : '1.1',
'host' : 'mqtt',
'short_message' : topic,
'_payload' : payload,
}
%}
{{ data | jsonify }}
Cheers!
from mqttwarn.
GH-686 fixes the flaw which lead to the error. mqttwarn 0.35.0 has been released, including the fix.
from mqttwarn.
Confirmed all working again with 0.35 many thanks, super quick!
from mqttwarn.
Wonderful. Thanks for your reply. Closing this.
from mqttwarn.
Related Issues (20)
- Remove `gss` service plugin in favor of `gss2`? HOT 3
- mqttwarn 0.34.0 sdist size change HOT 1
- mqttwarn nine years ago HOT 6
- Absorb mqttshark? HOT 5
- Documentation on Image-based installation is wrong HOT 3
- [Nextcloud] Verify thoroughness of implementation over Apprise
- [ntfy] Bug with notification messages longer than 76 characters HOT 5
- Improve ntfy documentation on authorization and/or add authorization header HOT 4
- Docker issue with pushbullet (mqttwarn-full) HOT 8
- [ntfy] Error if message contains newline character `\n` HOT 14
- [pushover] unable to decode base64 encoded image
- Nightly to latest docker build - what is the trigger for this? HOT 5
- Use `dynamic-imports` for loading Python code at runtime
- Pull effective recipient from message payload HOT 3
- Messages directed only to the first target when a format function is defined HOT 2
- TLS issues with mosquitto-2.0.18 HOT 6
- mqttwarn does not like py39-paho-mqtt-2.0.0 HOT 11
- ntfy title results in ''=?utf-8?q?' prefix? HOT 1
- Republish part of json to influxdb or mqtt HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqttwarn.