Rivian Prometheus Exporter

Export the Data for Use in Observability

Good to know: Unofficial Rivian Prometheus Exporter

Prometheus provides custom collectors to generate metrics to include in Observability platforms, you can write the exporters in supported client libraries.

I have written the Rivian Prometheus Exporter using the python client. You can deploy it using the Kubernetes resources below as well.

In the exporter, we have only one gauge (battery %) and couple of other counter metrics exposed.

Steps

  1. Code Up Rivian Exporter in Python for Prometheus.

  2. Dockerize the exporter, build container.

  3. Deploy on Kubernetes

  4. Scrape The Whip Metrics

  5. Inspect the Data Outcome

Exporter

/src/rivian_exporter.py

I am exposing the static gauge and counter metrics. But you can just modify it with your logic from another system.

In second step we will build our Docker container.

Container

Container blurb.

Now build it, and push.

Now that we have a container pushed, we can use it in our deployment.

Kubernetes

In the last third step you can deploy the collector on Kubernetes.

/deploy/deployment.yaml

Next is the service, I use MetalLB as it is my favorite thing ever basically, but expose the socket any which way you fancy.

/deploy/service.yaml

Create a namespace and add your Rivian Credentials as a secret:

Apply the Deployment and LoadBalancer (or NodePort)

If everything worked out, we should see a pair of fonzies running on our cluster for the deployment and the MetalLB LoadBalancer Service.

Deployment Ready
Services Ready

Data Inspection

Now hit the MetalLB Load balancer on port 5000 and bask in the glory of the exported metrics.

Notice the sweet name spacing with my Vehicle Id

Though, awesome, most arent impressed by metrics endpoints, but get set to get even more unimpressed looking at a round trip of errands using prometheus to explore the data.

You need to define a simple prometheus.yml

Then run it and hit http://localhost:9090 to explore the data time series in Prometheus.

Lets inspect the data running a couple of errands in the Whip.

So its like 3:PM or so EST, and I needed to go to the store, along the way, I stopped at Taco Bell, then drove home to Gun Lake. Total trip was about 20 miles or so, with 2 stops.

Gun Lake -> Taco Bell -> Grocery Store -> Gun Lake

Distance to Empty

I hope you appreciate the simplicity here, but prometheus told the story of my errands run... I started out with a full charge with an extended setting, drove 10 miles, did two stops very close to each other, then drove it back 10 miles. You can even see where I did some drive way shuffling before I plugged it in to charge to Standard.

Distance to Empty

Gear Status

This one wont win any visualization awards, but if you recall the metric we did was 0 = P, and anything else is 1 = in motion (whether backwards or forwards). You can clearly see the 3 errands and the park shuffling in the gear status as well.

Gear Status

Everything you see here available on Github

References

Github: https://github.com/prometheus/client_python

Docker

Kubernetes

Last updated