From 2d1678ed956616a9c16a1b142cc5e88c06b5cc91 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Fri, 17 Apr 2020 10:06:54 +0200 Subject: [PATCH] Add Docker * Add Dockerfile and prometheuscommunity. * Add promehteus common Version handler. * Update README. Signed-off-by: Ben Kochie --- Dockerfile | 12 ++++++++++++ Makefile | 1 + README.md | 25 +++++++++++++++++-------- go.mod | 1 + jsonexporter/version.go | 6 +++++- 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d556dfb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +ARG ARCH="amd64" +ARG OS="linux" +FROM quay.io/prometheus/busybox-${OS}-${ARCH}:glibc +LABEL maintainer="The Prometheus Authors " + +ARG ARCH="amd64" +ARG OS="linux" +COPY .build/${OS}-${ARCH}/json_exporter /bin/json_exporter + +EXPOSE 7979 +USER nobody +ENTRYPOINT [ "/bin/bind_exporter" ] diff --git a/Makefile b/Makefile index 8ddad46..8d9d81c 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ all:: # Needs to be defined before including Makefile.common to auto-generate targets DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le +DOCKER_REPO ?= prometheuscommunity include Makefile.common diff --git a/README.md b/README.md index 2f2deac..e3ef786 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ json_exporter ======================== +[![CircleCI](https://circleci.com/gh/prometheus-community/json_exporter.svg?style=svg)](https://circleci.com/gh/prometheus-community/json_exporter) A [prometheus](https://prometheus.io/) exporter which scrapes remote JSON by JSONPath. -Build -===== +# Build + ```sh -./gow get . -./gow build -o json_exporter . +make build ``` -Example Usage -============= +# Example Usage + ```sh $ cat example/data.json { @@ -68,7 +68,16 @@ example_value_count{environment="beta",id="id-A"} 1 example_value_count{environment="beta",id="id-C"} 3 ``` -See Also -======== +# Docker + +```console +docker run \ + -v config.yml:/config.yml + json_exporter \ + http://example.com/target.json \ + /config.yml +``` + +# See Also - [kawamuray/jsonpath](https://github.com/kawamuray/jsonpath#path-syntax) : For syntax reference of JSONPath. Originally forked from nicksardo/jsonpath(now is https://github.com/NodePrime/jsonpath). diff --git a/go.mod b/go.mod index 480bdbf..8c6c910 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/kawamuray/jsonpath v0.0.0-20160208140654-5c448ebf9735 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/prometheus/client_golang v1.5.1 + github.com/prometheus/common v0.9.1 github.com/prometheus/procfs v0.0.11 // indirect github.com/sirupsen/logrus v1.5.0 github.com/urfave/cli v1.22.4 diff --git a/jsonexporter/version.go b/jsonexporter/version.go index 86ed05d..882690c 100644 --- a/jsonexporter/version.go +++ b/jsonexporter/version.go @@ -13,4 +13,8 @@ package jsonexporter -const Version = "0.0.2" +import ( + "github.com/prometheus/common/version" +) + +var Version = version.Version