Prometheus Kafka Writer Microservice
[demo.git] / vnfs / DAaaS / microservices / prom-kafka-writer / README.md
1 # Prometheus Kafka Remote Writer
2
3 ![Architecture Diagram](./diagram.png)
4
5 Prometheus Kafka remote writer is a remote writer/adapter to publish metrics from prometheus to a remote storage like kafka.
6 The prom-kafka-writer microservice enables to register the remote endpoint and configures the kafka producer endpoint. 
7 Prometheus can then be configured to set the remote write to this endpoint and the metrics can be published.
8
9 ----
10 ## Install
11 ### Build docker images
12 ```bash
13 git clone https://github.com/onap/demo.git
14 DA_WORKING_DIR=$PWD/demo/vnfs/DAaaS
15 cd $DA_WORKING_DIR/microservices/prom-kafka-writer
16 docker build -f Dockerfile.ci . -t prom-kafka-writer:latest
17 ```
18 ### Deploy using Helm chart
19 ```bash
20 cd $DA_WORKING_DIR/deploy/collection/charts/prom-kafka-writer
21
22 # Modify the values.yaml
23 helm install -n pkw . -f values.yaml --namespace=edge1
24 ```
25 Verify the deployment
26 ```bash
27 kubectl get pods -n edge1 | grep prom-kafka-writer
28
29 NAME                                    READY   STATUS             RESTARTS   AGE
30 pkw-prom-kafka-writer-c6c89c579-jv6jt   1/1     Running            0          11m
31 ```
32
33 ## API
34 * Create Prometheus Kafka Writer endpoint
35
36 ```bash
37    //Request
38    curl -X POST \
39      http://prom-kafka-writer/pkw \
40      -H 'Content-Type: application/json' \
41      -d '{
42     "bootstrap.servers": "kafka-cluster-kafka-bootstrap.kafka.svc.cluster.local:9091",
43     "topic": "topic1",
44     "usePartition": false,
45     "compression.codec": "snappy"
46    }'
47 ```
48
49 * Delete Prometheus Kafka Writer endpoint
50           
51 ```bash
52     //Request
53     curl -X DELETE http://prom-kafka-writer/pkw/pkw0
54 ```
55
56 * List Prometheus Kafka Writers
57 ```bash
58     //Request
59     curl -X GET http://prom-kafka-writer/pkw
60 ```
61
62 * Publish to Kafka Writer
63 ```bash
64     //Request
65     curl -X POST http://prom-kafka-writer/pkw/pkw0/receive
66 ```