json_exporter
json_exporter copied to clipboard
Can this read a local json file ?
by f.ex. giving it a url like: file:///my/path/file.json ?
This exporter works with the multi-target pattern. So it accepts arbitrary target locations via the URL params. It could be extremely dangerous to open that up to local files on the exporter's filesystems.
It might be safer if a flag were used to limit to only files in a specific path. For example.
./json_exporter --probe.file-path=/my/path
Then you could probe with http://json-exporter.example.com:7979/probe?target=file.json
.
Hi!
Running 0.3.0 version, specified --probe.file-path=/tmp
, and receive
json_exporter: error: unknown long flag '--probe.file-path', try --help
But in help there is no --probe flag:
/ $ json_exporter --help
usage: json_exporter [<flags>]
Flags:
-h, --help Show context-sensitive help (also try --help-long and
--help-man).
--config.file=config.yml JSON exporter configuration file.
--web.listen-address=":7979"
The address to listen on for HTTP requests.
--config.check If true validate the config file and then exit.
--web.config="" [EXPERIMENTAL] Path to config yaml file that can enable TLS or
authentication.
--log.level=info Only log messages with the given severity or above. One of:
[debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt, json]
--version Show application version.
Also, tried to specify path in url, eg http://json-exporter.example.com:7979/probe?target=/tmp/my.json Got
Error response
Error code: 404
Message: File not found.
Error code explanation: HTTPStatus.NOT_FOUND - Nothing matches the given URI.
File /tmp/my.json exists and has valid json
So, how can I read json from file /tmp/my.json?
@rustycl0ck
@rustycl0ck is it possible to read local file?
@DAGorchakov , Reading from local file is a new feature request, it is not there right now.
so by now should I configure the exporter to scrape local json data by modifying prometheus.yml (the prometheus configuration file)?
Simple suggestion to handle that use-case. take a simple webserver like python -m SimpleHTTPServer 9000
(or Gunicorn or nginx) and use localhost:9000/your.json
as url for the exporter. For production use you should go the extra mile to harden & monitor the server. But actually works very well