Skip to content

Commit

Permalink
First version of the ccloudexporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dabz committed Jan 9, 2020
1 parent 3021896 commit 17e87d2
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.13

WORKDIR /go/src/app

RUN git clone -b v1.3.0 https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix /usr && make && make install
RUN go get github.com/Dabz/ccloudexporter/cmd/ccloudexporter
RUN go install github.com/Dabz/ccloudexporter/cmd/ccloudexporter

CMD ["ccloudexporter"]
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,42 @@

A simple prometheus exporter that can be used to extract metrics from [Confluent Cloud Metric API](https://docs.confluent.io/current/cloud/metrics-api.html).
By default, the scrapper will be exposing the metrics on [port 2112](http://localhost:2112)
In order to use the scrapper, the following environment variable need to be specified:
To use the scrapper, the following environment variables need to be specified:

* `CCLOUD_USER`: Your Confluent Cloud login
* `CCLOUD_PASSWORD`: Your Confluent Cloud password

`CCLOUD_USER` and `CCLOUD_PASSWORD` environment variable will be used to invoke the https://api.telemetry.confluent.cloud endpoint
`CCLOUD_USER` and `CCLOUD_PASSWORD` environment variables will be used to invoke the https://api.telemetry.confluent.cloud endpoint.

## Usage
```
./ccloudexporter <cluster_id> [kafka client configuration]
````
## Examples
## Building and executing
```
go get github.com/Dabz/ccloudexporter/cmd/ccloudexporter
go install github.com/Dabz/ccloudexporter/cmd/ccloudexporter
export CCLOUD_USER=[email protected]
export CCLOUD_PASSWORD=totopassword
./ccloudexporter lkc-abc123
```
## How to build
## Using docker
```
docker run -e CCLOUD_USER=$CCLOUD_USER -e CCLOUD_PASSWORD=$CCLOUD_PASSWORD dabz/ccloudexporter:latest ccloudexporter lkc-abc123
```
## Using docker-compose
```
export CCLOUD_USER=[email protected]
export CCLOUD_PASSWORD=totopassword
export CCLOUD_CLUSTER=lkc-abc123
docker-compose up -d
```
TODO
## How to build
```
go get github.com/Dabz/ccloudexporter/cmd/ccloudexporter
```
13 changes: 9 additions & 4 deletions cmd/ccloudexporter/ccloudexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
package main

import (
"os"
"fmt"
"net/http"
"github.com/Dabz/ccloudexporter/cmd/internal/scrapper"
"github.com/prometheus/client_golang/prometheus/promhttp"
"gopkg.in/confluentinc/confluent-kafka-go.v1/kafka"
"github.com/Dabz/cmd/internal/scrapper"
"net/http"
"os"
)

func main() {
Expand Down Expand Up @@ -46,5 +46,10 @@ func main() {
scrapper.FetchMetricsFromEndpointRoutine(cluster)

http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":2112", nil)
err := http.ListenAndServe(":2112", nil)
if err != nil {
panic(err)
}

fmt.Println("Listening on http://localhost:2112/metrics")
}
19 changes: 19 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.1'

services:
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/prometheus.yml
command:
- '--config.file=/prometheus.yml'
ports:
- 9090:9090
restart: always
ccloud_exporter:
build: ./
environment:
CCLOUD_USER: ${CCLOUD_USER}
CCLOUD_PASSWORD: ${CCLOUD_PASSWORD}
CCLOUD_CLUSTER: ${CCLOUD_CLUSTER}
command: ccloudexporter ${CCLOUD_CLUSTER}
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.1'

services:
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/prometheus.yml
command:
- '--config.file=/prometheus.yml'
ports:
- 9090:9090
restart: always
ccloud_exporter:
image: dabz/ccloudexporter
environment:
CCLOUD_USER: ${CCLOUD_USER}
CCLOUD_PASSWORD: ${CCLOUD_PASSWORD}
CCLOUD_CLUSTER: ${CCLOUD_CLUSTER}
command: ccloudexporter ${CCLOUD_CLUSTER}
8 changes: 8 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'ccloudexporter'
scrape_interval: 15s
static_configs:
- targets: ['ccloud_exporter:2112']

0 comments on commit 17e87d2

Please sign in to comment.