To build and start the screenly/balena-prometheus-exporter
project, follow the steps outlined below:
Step 1: Clone the Repository
First, clone the repository to your local machine using the following command:
git clone https://github.com/screenly/balena-prometheus-exporter.git
cd balena-prometheus-exporter
Step 2: Build the Docker Image
Use Docker to build the image for the project. The command below tags the image as balena-exporter
.
docker build -t balena-exporter .
Step 3: Run the Docker Container
Once the image is built, run the container. Make sure to set the BALENA_TOKEN
environment variable to authenticate with the Balena API. The command below will run the container in detached mode, mapping port 8000 on your host to port 8000 in the container.
docker run -d \
--name balena-exporter \
-p 8000:8000 \
-e BALENA_TOKEN=your_balena_token_here \
balena-exporter
Optional - Set CRAWL_INTERVAL
If you wish to set a custom crawl interval, passed as an environment variable when running the container. If not specified, it defaults to 60 seconds.
-e CRAWL_INTERVAL=your_desired_interval_here
Step 4: Verify the Setup
You should now be able to verify that the exporter is running correctly by sending a request to port 8000 using curl
:
curl http://localhost:8000/metrics
This command should return metrics in Prometheus format, confirming that the exporter is functioning properly.
Environment Variables
BALENA_TOKEN
: This token is required for accessing the Balena API. Make sure to set it with a valid token from your Balena account.CRAWL_INTERVAL
(optional): Interval for crawling metrics, in seconds. The default value is set to 60 seconds.
Dependencies
The application requires the following libraries, which you can find in the requirements.txt
file:
certifi==2024.7.4
charset-normalizer==3.1.0
idna==3.4
prometheus-client==0.16.0
requests==2.31.0
urllib3==1.26.18
You can review the full project structure to understand how components interact, but the primary functionality leverages requests
to communicate with the Balena API and prometheus-client
to expose metrics.
For more information about the project, refer to the README file located in the repository.
Source: README.md, requirements.txt