Skip to content

Commit

Permalink
fix docker build (ClickHouse#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
f1yegor committed Oct 16, 2018
1 parent ed5fbec commit ba6cbdd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM sdurrheimer/alpine-golang-make-onbuild
MAINTAINER Yegor Andreenko
FROM golang:1.11 AS BUILD

EXPOSE 9116
MAINTAINER Roman Tkalenko

ADD . /go/src/github.com/f1yegor/clickhouse_exporter

WORKDIR /go/src/github.com/f1yegor/clickhouse_exporter

RUN make init && make

FROM frolvlad/alpine-glibc

COPY --from=BUILD /go/bin/clickhouse_exporter /usr/local/bin/clickhouse_exporter

ENTRYPOINT ["/usr/local/bin/clickhouse_exporter"]

CMD ["-scrape_uri=http://localhost:8123"]

EXPOSE 9116
17 changes: 1 addition & 16 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewExporter(uri url.URL, insecure bool, user, password string) *Exporter {
metricsURI.RawQuery = q.Encode()

asyncMetricsURI := uri
q.Set("query", "select * from system.asynchronous_metrics")
q.Set("query", "select metric, value from system.asynchronous_metrics")
asyncMetricsURI.RawQuery = q.Encode()

eventsURI := uri
Expand Down Expand Up @@ -203,24 +203,9 @@ func (e *Exporter) handleResponse(uri string) ([]byte, error) {
return nil, fmt.Errorf("Status %s (%d): %s", resp.Status, resp.StatusCode, data)
}

if strings.Contains(uri, "system.metrics") || strings.Contains(uri, "system.events") {
data = DataFix(data)
}
return data, nil
}

func DataFix(data []byte) []byte {
datastr := string(data)
var fixedData string
for _, line := range strings.Split(datastr, "\n") {
parts := strings.Fields(line)
if len(parts) >= 2 {
fixedData = fixedData + fmt.Sprintf("%v %v\n", parts[0], parts[1])
}
}
return []byte(fixedData)
}

type lineResult struct {
key string
value int
Expand Down

0 comments on commit ba6cbdd

Please sign in to comment.