|
| 1 | +Here’s an updated README to include details about Tesla's Fleet Telemetry project and the Protobuf definition: |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +# Fleet Telemetry Consumer |
| 6 | + |
| 7 | +This application consumes vehicle telemetry data from Tesla's [Fleet Telemetry project](https://github.com/teslamotors/fleet-telemetry), processes it using Protobuf, and exports metrics to Prometheus. It is intended to be deployed in a Kubernetes environment and can be monitored using Prometheus. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Kafka Consumer**: Consumes messages from a Kafka topic (`tesla_V` by default) containing vehicle telemetry data from Tesla’s Fleet Telemetry project. |
| 12 | +- **Protobuf Processing**: Deserializes the Protobuf data defined in Tesla's [vehicle_data.proto](https://github.com/teslamotors/fleet-telemetry/blob/main/protos/vehicle_data.proto) and processes telemetry information such as location, door status, and sensor values. |
| 13 | +- **Prometheus Metrics**: Exposes vehicle telemetry data as Prometheus metrics, enabling real-time monitoring. |
| 14 | +- **Docker & Kubernetes**: Dockerized and ready for Kubernetes deployment with `Kustomize` support. |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- **Docker**: Ensure Docker is installed to build and run the application. |
| 19 | +- **Kafka**: A running Kafka cluster with the topic `tesla_V`. |
| 20 | +- **Prometheus**: To scrape metrics exposed by the app. |
| 21 | +- **Kubernetes**: For deployment using `Kustomize`. |
| 22 | + |
| 23 | +## Tesla's Fleet Telemetry Data |
| 24 | + |
| 25 | +The application consumes telemetry data structured according to Tesla's [Protobuf definition](https://github.com/teslamotors/fleet-telemetry/blob/main/protos/vehicle_data.proto). The Protobuf message `Payload` includes fields for various vehicle data such as: |
| 26 | + |
| 27 | +- `LocationValue`: GPS coordinates (latitude, longitude) |
| 28 | +- `DoorValue`: The open/closed status of the vehicle’s doors |
| 29 | +- `DoubleValue`, `FloatValue`, `IntValue`, etc.: Different sensor values |
| 30 | +- `TimeValue`: Timestamp data related to telemetry events |
| 31 | + |
| 32 | +The application extracts and processes these fields, converting them into Prometheus metrics. |
| 33 | + |
| 34 | +## Configuration |
| 35 | + |
| 36 | +The application requires a configuration file in JSON format. This file contains settings for Kafka consumer configuration. By default, the app looks for `config.json`. |
| 37 | + |
| 38 | +### Example `config.json`: |
| 39 | +```json |
| 40 | +{ |
| 41 | + "bootstrap.servers": "localhost:9092", |
| 42 | + "group.id": "fleet-telemetry-consumer", |
| 43 | + "auto.offset.reset": "earliest" |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +## Build and Run |
| 48 | + |
| 49 | +### Build Docker Image |
| 50 | + |
| 51 | +To build the Docker image for the consumer: |
| 52 | + |
| 53 | +```bash |
| 54 | +docker buildx build --platform linux/amd64 --load -t fleet-telemetry-consumer . |
| 55 | +``` |
| 56 | + |
| 57 | +### Run with Docker Compose |
| 58 | + |
| 59 | +To start the application using Docker Compose: |
| 60 | + |
| 61 | +```bash |
| 62 | +docker compose up --build |
| 63 | +``` |
| 64 | + |
| 65 | +### Kubernetes Deployment |
| 66 | + |
| 67 | +To deploy the application in a Kubernetes environment using Kustomize, use the following `kustomization.yaml` configuration: |
| 68 | + |
| 69 | +Apply the configuration with: |
| 70 | + |
| 71 | +```bash |
| 72 | +kubectl apply -k kustomization |
| 73 | +``` |
| 74 | + |
| 75 | +This will deploy the fleet telemetry consumer into the Kubernetes cluster. |
| 76 | + |
| 77 | +## Prometheus Metrics |
| 78 | + |
| 79 | +The consumer exposes metrics at `/metrics` on port `2112`. Prometheus can scrape this endpoint to monitor the application. The metrics include various vehicle telemetry data such as: |
| 80 | + |
| 81 | +- Vehicle location |
| 82 | +- Door states |
| 83 | +- Time and speed metrics |
| 84 | +- Boolean and numerical telemetry data |
| 85 | + |
| 86 | +### Sample Prometheus Query: |
| 87 | + |
| 88 | +```promql |
| 89 | +vehicle_data{field="Latitude"} |
| 90 | +``` |
| 91 | + |
| 92 | +## Contributions |
| 93 | + |
| 94 | +Feel free to open issues or submit pull requests if you'd like to contribute! |
0 commit comments