A spring-boot application that calls elasticsearch's cluster and node REST endpoints and converts them to prometheus-friendly metric formats.
The following settings need to be set as environment variables in the context of the running application.
For example, if running the application in docker, you'll need to set values via the --env
or -e
switches in the docker run command,
or set them in the environment
section of your docker-compose file (or in the associated .env
file if you use it).
Values can be:
ERROR
WARN
INFO
(default)DEBUG
TRACE
The path to where you want the logs stored.
Default: logs
The log file is called: log.log
See
src/main/resources/application.properties
andsrc/main/resources/logback-spring.xml
for log settings.
This is the host that you want stat requests to go to.
Default: localhost
This should be the port that you want to talk to your ES cluster on.
Default: 9200
Values can be:
http
(default)https
If you set an incorrect value, the system will likely error and fail.
Values can be:
basic:USERNAME:PASSWORD
none
(default)
If anything other than the above two values are set, the default setting applies.
- Pull the built container
- Copy the
elastiprom.service
file to/etc/systemd/system/
- Create a
.env
file with your settings in it in/usr/share/elastiprom/
- Reload systemctl:
sudo systemctl daemon-reload
- Start elastiprom:
sudo service elastiprom restart
- Pull the built container
docker-compose up --env-file=env
- Build the container (in project root):
docker build -t elastiprom:latest .
- Run it:
docker run --rm -it -p 8080:8080 --name elastiprom --env-file env elastiprom:latest
- Upload the jar file to
/usr/share/elastiprom/
. - Copy the
elastiprom.service
file to/etc/systemd/system/
- Create a
.env
file with your settings in it in/usr/share/elastiprom/
- Reload systemctl:
sudo systemctl daemon-reload
- Start elastiprom:
sudo service elastiprom restart
Make sure that you configure IntelliJ to use the gradle wrapper when running the project.
- Open the gradle tool tab
- Navigate to
tasks
->application
->bootRun
- Right click and choose:
Edit 'elastiprom [bootRun]'
- In the resulting dialog, under the
Configuration
tab, click on the icon at the right of theEnvironment variables
input - Enter your environment settings (
ES_HOST
,ES_PORT
etc)
Now you can run this task and it will start up with the right settings in place.
The main acknowlegement must go to Jacek S, where most of this code comes from.
After attempting to fork that repo's elasticsearch-plugin and write a version for the latest elastic, and realising that elastic had protected a bunch of methods required for it to work, then I decided to separate it from elasticsearch and run it as a spring-boot instead.