Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock dependencies #33

Merged
merged 3 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
vendor
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nginx_exporter
vendor
30 changes: 19 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
FROM golang:1.9
LABEL maintainer="@discordianfish"
WORKDIR /go/src/github.com/discordianfish/nginx_exporter
ENV GOOS=linux CGO_ENABLED=0
COPY . .
RUN go get -d && go build
FROM golang:1.9
LABEL maintainer="@discordianfish"

# Install dep tool
ARG DEP_VERSION=v0.3.2
ARG DEP_SHA256=322152b8b50b26e5e3a7f6ebaeb75d9c11a747e64bbfd0d8bb1f4d89a031c2b5
RUN wget -q https://github.com/golang/dep/releases/download/${DEP_VERSION}/dep-linux-amd64 -O /usr/local/bin/dep \
&& echo "${DEP_SHA256} /usr/local/bin/dep" | sha256sum -c - \
&& chmod 755 /usr/local/bin/dep

FROM quay.io/prometheus/busybox:glibc
EXPOSE 9113
COPY --from=0 /go/src/github.com/discordianfish/nginx_exporter/nginx_exporter /bin/
USER nobody
ENTRYPOINT [ "/bin/nginx_exporter" ]
ENV GOOS=linux CGO_ENABLED=0
WORKDIR /go/src/github.com/discordianfish/nginx_exporter
COPY Gopkg.* *.go ./
RUN dep ensure --vendor-only \
&& go install

FROM quay.io/prometheus/busybox:glibc
EXPOSE 9113
COPY --from=0 /go/bin/nginx_exporter /usr/local/bin/
USER nobody
ENTRYPOINT [ "/usr/local/bin/nginx_exporter" ]
87 changes: 87 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.8.0"

[[constraint]]
branch = "master"
name = "github.com/prometheus/common"
6 changes: 3 additions & 3 deletions nginx_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/log"
"github.com/prometheus/common/log"
)

const (
Expand Down Expand Up @@ -167,7 +167,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
e.mutex.Lock() // To protect metrics from concurrent collects.
defer e.mutex.Unlock()
if err := e.collect(ch); err != nil {
log.Printf("Error scraping nginx: %s", err)
log.Errorf("Error scraping nginx: %s", err)
e.scrapeFailures.Inc()
e.scrapeFailures.Collect(ch)
}
Expand All @@ -182,7 +182,7 @@ func main() {
exporter := NewExporter(*nginxScrapeURI)
prometheus.MustRegister(exporter)

log.Printf("Starting Server: %s", *listeningAddress)
log.Infof("Starting Server: %s", *listeningAddress)
http.Handle(*metricsEndpoint, prometheus.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
Expand Down