diff --git a/README.md b/README.md index 90a5926..411469a 100644 --- a/README.md +++ b/README.md @@ -49,33 +49,35 @@ Bonus Pretty easy with *kubernetes*. Just run the exporter along the app in a pod with an ReplicationController: + + _Note: Config is just an proof of concept, not fully tested:_ ```yaml - apiVersion: v1 - kind: ReplicationController - metadata: - name: replicatedApp - spec: - replicas: 100 - selector: - app: exportedApp - template: - metadata: - name: podApp - annotations: - prometheus.io/scrape: true - prometheus.io/port: 8081 - labels: - app: exportedApp - spec: - containers: - - name: challenge - image: beorn7/syseng-challenge - ports: - - containerPort: 8080 - - name: exporter - image: exporter - ports: - - containerPort: 8081 + apiVersion: v1 + kind: ReplicationController + metadata: + name: replicatedapp + spec: + replicas: 100 + selector: + app: exportedapp + template: + metadata: + name: podapp + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8081" + labels: + app: exportedapp + spec: + containers: + - name: challenge + image: beorn7/syseng-challenge + ports: + - containerPort: 8080 + - name: exporter + image: exporter + ports: + - containerPort: 8081 ``` Just use the service discovery in prometheus: @@ -94,7 +96,7 @@ Bonus target_label: __address__ - source_labels: [__meta_kubernetes_pod_name] action: replace - target_label: podApp + target_label: pod ``` DNS discovery may be an alternative, for example with coredns. diff --git a/exporter.go b/exporter.go index a2445bb..fc5a854 100644 --- a/exporter.go +++ b/exporter.go @@ -26,7 +26,7 @@ var ( listenAddress = flag.String("listen", ":8080", "The address to listen on for HTTP requests.") endpointApp = flag.String("endpoint", "http://localhost:8050/stats", "HTTP API address of the application") timeoutApp = flag.Int("timeout", 500, "Connection timeout in ms") - environment = flag.String("environment", "", "Optional environment which will be added to the exported metrics") + environment = flag.String("environment", "", "Optional value for an label environment which will be added to the exported metrics") prometheusConstLabel = parseConstLabel() ) diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..24d57af --- /dev/null +++ b/test.yml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: replicatedapp +spec: + replicas: 100 + selector: + app: exportedapp + template: + metadata: + name: podapp + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8081" + labels: + app: exportedapp + spec: + containers: + - name: challenge + image: beorn7/syseng-challenge + ports: + - containerPort: 8080 \ No newline at end of file