Skip to content

Commit

Permalink
Added example with metrics and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinapathak committed Jul 11, 2020
1 parent ac7f7d7 commit b01b11c
Show file tree
Hide file tree
Showing 9 changed files with 600 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ coverage*
# Ignore example binaries
examples/configurableListener/configurableListener
examples/basicListener/basicListener
examples/metricListener/metricListener

# Ignore the various build artifacts
.ignore
Expand Down
22 changes: 22 additions & 0 deletions examples/metricListener/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:alpine as builder
MAINTAINER Kristina Spring <kristina_spring@comcast.com>

WORKDIR /go/src/github.com/xmidt-org/wrp-listener/examples/metricListener

RUN apk add --update git curl

COPY . .

RUN go build -o metricListener_linux_amd64

FROM alpine

RUN apk --no-cache add ca-certificates
RUN mkdir -p /etc/metricListener
VOLUME /etc/metricListener

EXPOSE 8080

COPY --from=builder /go/src/github.com/xmidt-org/wrp-listener/examples/metricListener/metricListener_linux_amd64 /
COPY docFiles/metricListener.yaml /
ENTRYPOINT ["/metricListener_linux_amd64"]
40 changes: 40 additions & 0 deletions examples/metricListener/docFiles/metricListener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
primary:
address: ":443"
pprof:
address: ":9999"
readTimeout: "15s"
idleTimeout: "15s"
metric:
address: ":9390"
metricsOptions:
namespace: "test"
subsystem: "listener"
readTimeout: "15s"
idleTimeout: "15s"
log:
file: "/var/log/metricListener/metricListener.log"
level: "INFO"
json: "true"
# log:
# file: "stdout"
# level: "INFO"
# json: true

authHeader: "X-Webpa-Signature"
authDelimiter: "="
webhookRequest:
config:
url: "http://localhost:443/api/v1/endpoint"
secret: "super secret"
events: ["device-status.*"]
webhookRegistrationURL: "https://localhost:8090/api/v2/hook"
webhookTimeout: "1m"
webhookRegistrationInterval: "1m"
endpoint: "/endpoint"
responseCode: 202
jwt:
requestHeaders:
authURL: ""
timeout: 1m
buffer: 5s
41 changes: 41 additions & 0 deletions examples/metricListener/docFiles/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# my global config
global:
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 1s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
# rule_files:
# - "first.rules"
# - "second.rules"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:9090']

- job_name: 'docker'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:9323']
- job_name: 'metriclistener'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:9390']
31 changes: 31 additions & 0 deletions examples/metricListener/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.4'

services:
# metriclistener:
# image: listener:${LISTENER_VERSION}
# container_name: metriclistener
# restart: on-failure
# ports:
# - 7100:7100
# - 7101:7101
# - 7102:7102
# - 7103:7103
# volumes:
# - ./docFiles/metricListener.yaml:/etc/metricListener/metricListener.yaml
# - ./docFiles/public.pem:/etc/metricListener/public.pem
# networks:
# - back-tier

prometheus:
image: prom/prometheus
container_name: prometheus
networks:
- back-tier
ports:
- 9090:9090
volumes:
- ./docFiles/prometheus.yml:/prometheus-data/prometheus.yml
command: --config.file=/prometheus-data/prometheus.yml

networks:
back-tier:
22 changes: 22 additions & 0 deletions examples/metricListener/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module github.com/xmidt-org/wrp-listener/examples/metricListener

go 1.12

require (
github.com/Comcast/webpa-common v1.3.0 // indirect
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/c9s/goprocinfo v0.0.0-20190309065803-0b2ad9ac246b // indirect
github.com/go-kit/kit v0.8.0
github.com/goph/emperror v0.17.2
github.com/gorilla/mux v1.7.3
github.com/influxdata/influxdb v1.7.7 // indirect
github.com/justinas/alice v0.0.0-20171023064455-03f45bd4b7da
github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/client_golang v1.0.0 // indirect
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.4.0
github.com/xmidt-org/bascule v0.3.1
github.com/xmidt-org/webpa-common v1.3.0
github.com/xmidt-org/wrp-listener v0.1.1
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
)
Loading

0 comments on commit b01b11c

Please sign in to comment.