8.4 JSON Exporter
The JSON Exporter fetches data from JSON endpoints, like the LYX price from CoinGecko. Having access to live price metrics allows you to monitor market performance and monitor financial metrics against validator number or participation rate.
Further details about node analytics can be found on the Monitoring Tools page in the ๐ง Theory section.
The following steps are performed on your ๐ node server.
1. Create System Userโ
Running services as a system user with minimal privileges is a best practice, limiting damage if compromised. The JSON Exporter user will only be able to read and execute service-specific files. Use the system's user creation tool to add a new one.
sudo adduser --system json-exporter-worker --group --no-create-home
Full Command Explanation
Flag | Description |
---|---|
--system | Creates a system user, used to run services and daemons rather than for people to log in with. |
--group | Creates a new group with the same name as the user. |
--no-create-home | Prevents creation of a home directory since the service does not need one. |
If you want to confirm that the user has been created, you can search for it within the password file, housing all essential information for each user account. Using the search tool grep, we can check if the user exists within the file.
grep "json-exporter-worker" /etc/passwd
The output should look similar to this:
json-exporter-worker:x:115:121::/home/json-exporter-worker:/usr/sbin/nologin
2. Install JSON Exporterโ
To add the JSON Exporter tool to your node, you have to install it's package.
Depending on the Current JSON Exporter Release the version and filenames might differ. Please ensure to use the latest release for best security and stability. As of July 2025 it is version 0.7.0.
2.1 Download Archive: Move to the home directory and download the latest version.
cd
wget https://github.com/prometheus-community/json_exporter/releases/download/v0.7.0/json_exporter-0.7.0.linux-amd64.tar.gz
2.2 Extract Files: Unpack the archive using Ubuntuโs archiving tool.
tar xzfv json_exporter-0.7.0.linux-amd64.tar.gz
The tar
command extracts x
the uncompressed z
archive from the file path f
using verbose v
status messages.
2.3 Move Binary to System Path: Move the JSON Exporter binary to your system path.
sudo cp json_exporter-0.7.0.linux-amd64/json_exporter /usr/local/bin/
2.4 Assign Permissions: Set the correct owner and access rights.
sudo chown json-exporter-worker:json-exporter-worker /usr/local/bin/json_exporter
sudo chmod 755 /usr/local/bin/json_exporter
Full Command Descriptions
Setting | Description |
---|---|
sudo chown <user>:<user> <directory> | Assign ownership to a single folder or file. |
sudo chmod 755 <directory> | Set readable permissions for everyone, typically for general files. |
2.5 Cleanup Installation Files: Delete leftover archive and extracted folder.
rm -rf json_exporter-0.7.0.linux-amd64
rm json_exporter-0.7.0.linux-amd64.tar.gz
3. Price Configurationโ
Create a configuration file that will be used for the API call to fetch the current LYX price.
3.1 Create Config Directory and File: Choose a separate folder and create a config file using your preferred text editor.
sudo mkdir /etc/json_exporter/
- Vim
- Nano
sudo vim /etc/json_exporter/json_exporter.yaml
sudo nano /etc/json_exporter/json_exporter.yaml
3.2 Paste Configuration: Add the CoinGecko API configuration structure.
- EUR
- USD
modules:
default:
metrics:
- name: lyxeur
path: "{.lukso-token.eur}"
help: LUKSO (LYX) Price in EUR
modules:
default:
metrics:
- name: lyxusd
path: "{.lukso-token.usd}"
help: LUKSO (LYX) Price in USD
Ensure the correct formatting of double-spaces for the correct use of the API calls.
3.3 Restrict Permissions: Change the ownership of the configuration file to the service user.
sudo chown -R json-exporter-worker:json-exporter-worker /etc/json_exporter/
4. Service Configurationโ
Once the binary and API files are in place, we can create a service configuration for the exporter, so it automatically starts during boot and restarts during crashes. The configuration will also check for logging before it starts up and uses the previously created user.
4.1 Create Service File: Create a system service file using your preferred text editor.
- Vim
- Nano
sudo vim /etc/systemd/system/json_exporter.service
sudo nano /etc/systemd/system/json_exporter.service
4.2 Add Configuration: Paste the following content using your preferred logging tool, then save and exit the file.
Further details on Journal and System Logging can be found on the Utility Tools page in the the ๐ง Theory section.
- Journal Logging
- System Logging
[Unit]
Description=JSON Exporter
Documentation=https://github.com/prometheus-community/json_exporter
After=network.target network-online.target
[Service]
User=json-exporter-worker
Group=json-exporter-worker
Type=simple
ExecStart=/usr/local/bin/json_exporter --config.file /etc/json_exporter/json_exporter.yaml
Restart=always
RestartSec=5
SyslogIdentifier=json_exporter
StandardOutput=journal
StandardError=journal
ProtectSystem=full
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]
Description=JSON Exporter
Documentation=https://github.com/prometheus-community/json_exporter
After=network.target network-online.target
[Service]
User=json-exporter-worker
Group=json-exporter-worker
Type=simple
ExecStart=/usr/local/bin/json_exporter --config.file /etc/json_exporter/json_exporter.yaml
Restart=always
RestartSec=5
SyslogIdentifier=json_exporter
StandardOutput=syslog
StandardError=syslog
ProtectSystem=full
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Full Property Explanation
Property | Description |
---|---|
Description | A human-readable description of the service shown in systemctl status . |
Documentation | Link to documentation of the software that is being used for this service file. |
After | - network.target : Ensures networking setup enabled before service is started. - network-online.target : Waits for network to be fully online before service is started. |
User | Executes the service as the json-exporter-worker user. |
Group | Executes the service under the json-exporter-worker group. |
Type | Indicates running at a simple service in the foreground without forking. |
ExecStart | Link to binary at /usr/local/bin/json_exporter , started with the terminal command. |
Restart | Restarts the service always for a variety of reasons, errors, or timeouts. |
RestartSec | Delay in seconds before restarting the service. |
SyslogIdentifier | Tags logs from the service with json_exporter to help distinguish them. |
StandardOutput | Sends regular service logs to the journal or syslog system. |
StandardError | Sends error service logs to the journal or syslog system. |
ProtectSystem | Restricts filesystem write access outside of the service runtime. |
NoNewPrivileges | Prevents privilege escalation which processes can be apply for. |
PrivateTmp | Creates an isolated /tmp directory for the service. |
WantedBy | Binds the service to the multi-user.target , so it starts during all boot processes. |
If you renamed the user, make sure to update both User
and Group
values to prevent running the service as root
.
5. Start the Exporter Serviceโ
After setting up the service, you can enable and start the system service.
5.1 Reload Daemon: Reload the system daemon to include the new service.
sudo systemctl daemon-reload
5.2 Start Service: Start the Node Exporter service using the system control.
sudo systemctl start json_exporter
5.3 Enable Autostart on Boot: Enable the service to start automatically during boot.
sudo systemctl enable json_exporter
The output should look similar to this:
Created symlink /etc/systemd/system/multi-user.target.wants/json_exporter.service โ /etc/systemd/system/json_exporter.service.
6. Check Service Statusโ
You can fetch the current status from the system control to check if the JSON Exporter service is running and configured correctly. The command will display whether it is active, enabled, or disabled and show recent log entries.
sudo systemctl status json_exporter
The output should look similar to this:
โ json_exporter.service - JSON Exporter
Loaded: loaded (/etc/systemd/system/json_exporter.service; enabled; vendor preset: enab>
Active: active (running) since [DATE]; [TIME] ago
Docs: https://github.com/prometheus-community/json_exporter
Main PID: 88174 (json_exporter)
Tasks: 14 (limit: 38043)
Memory: 7.6M
CPU: 139ms
CGroup: /system.slice/json_exporter.service
โโ88174 /usr/local/bin/json_exporter --config.file /etc/json_exporter/json_expo>
[DATE] [TIME] [USER] json_exporter[88174]: net/http.HandlerFunc.ServeHTTP(0xc00002408>...
Maintenanceโ
Proper maintenance ensures that all the components are working as intended and can be updated on the fly.
Logging: Check the latest status of the system service.
- Journal Logging
- System Logging
sudo journalctl -f -u json_exporter
sudo tail -f /var/log/syslog | grep json_exporter
Restarting: If you made any changes or updates to configuration, reload the system daemon and start the exporter.
sudo systemctl daemon-reload
sudo systemctl restart json_exporter
Stopping: You can stop the exporter using the system control.
sudo systemctl stop json_exporter
Further information about system control or logging can be found on the Utility Tools page in the ๐ง Theory section.
Revert Setupโ
If something went wrong, you can remove the user or delete the service and related files all together.
1. Stop and Disable the Service: Stop the tool and remove it's service link from the system's boot.
sudo systemctl stop json_exporter
sudo systemctl disable json_exporter
2. Remove the Service and Config Files: Delete the configurations and reload the system daemon.
sudo rm /etc/systemd/system/json_exporter.service
sudo rm -rf /etc/json_exporter
sudo systemctl daemon-reload
3. Delete Binary: Remove the executable JSON Exporter from your system.
sudo rm -rf /usr/local/bin/json_exporter
4. Remove User and Group: Prune the user and all it's cached configurations.
sudo deluser --remove-all-files json-exporter-worker
sudo delgroup json-exporter-worker