Tracee exposes a metrics endpoint.
This makes it possible to monitor Tracee like other cloud native workloads.
In this tutorial, we will showcase how to access Tracee metrics through Prometheus and Grafana running through docker containers.
The tutorial can easily adapted to Kubernetes workloads with the configuration provided.
The following tools must be available for use, they can all be installed either
through docker or installed/built on your machine. Note that you need to be on a Linux machine to follow the Docker tutorial.
Alternative, on a MacBook it is possible to use Vagrant with Parallels as detailed in the following tutorial:
Running Tracee on Mac with Parallels and Vagrant
Install Prometheus or pull it's Docker image. Then create the following
configuration file, call it prometheus.yml to scrape Tracee:
# A scrape configuration containing exactly one endpoint to scrape:# Here it's Tracee.scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.-job_name:'tracee'# Override the global default and scrape targets from this job every 5 seconds.scrape_interval:5smetrics_path:/metrics#Scrape tracee's default metrics hosts.#If forwarding different ports make sure to change these addresses.static_configs:-targets:['localhost:3366']
Note that the localhost:3366 might have to be replaced with your IP address. The IP address can be found with the following command:
/sbin/ifconfig
We can then start Prometheus with the following command:
prometheus --config.file=/path/to/prometheus.yml
Or alternatively with docker:
docker run \ -p 9090:9090 \ -v ./prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus
Ensure that prometheus can scrape the Tracee target: Open the Prometheus UI at http://localhost:9090
Under Status < Targets will be the scrape targets listed.
If successful, move to the next step, otherwise consult with the Prometheus documentation.
Run Grafana to display Tracee's Prometheus Metrics¶
After successfully deploying Tracee and Prometheus we may now run Grafana to
visualize it's metrics.
Install Grafana using the Grafana container image:
docker run -d -p 3000:3000 --name=grafana grafana/grafana-enterprise
Next, you should be able to access the Grafana UI throug: http://localhost:3000.
After entering the website, logging in with username and password admin (and
changing your password if you wish), you should see the homepage:
Add your data source by hovering the configuration tab (the gear icon),
selecting "Data Sources" and pressing "Add Data Source" at the top left. Create
a Prometheus Data Source and point it's URL to the relevant location (usually
http://localhost:9090)
Note that you might have to use your local IP address again instead of localhost.
You may now either create your own Dashboard or import our default dashboard.
After adding the data source hover on the plus icon in the sidebar and select
"Import". Press "Upload JSON File" at the top of the page and select the
downloaded json from your file browser. Change the name and Dashboard UID if
you wish and press "Import" to finish.