Skip to content

Commit

Permalink
ClickHouse scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinskiy committed Feb 21, 2024
1 parent 5e1cce8 commit e6cf0ac
Show file tree
Hide file tree
Showing 35 changed files with 1,195 additions and 2,144 deletions.
8 changes: 8 additions & 0 deletions build/clickhouse-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@
</shard>
</test_shard_aggregator>
</remote_servers>
<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
<status_info>true</status_info>
</prometheus>
</clickhouse>
4 changes: 4 additions & 0 deletions build/scrape-clickhouse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

curl -H "Content-Type: application/yaml" --data-binary "@$(dirname "$0")/scrape-clickhouse.yml" localhost:10888/api/prometheus
echo
8 changes: 8 additions & 0 deletions build/scrape-clickhouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global:
scrape_interval: 5s
scrape_configs:
- job_name: clickhouse
static_configs:
- targets: ['127.0.0.1:9363']
labels:
service: '1'
8 changes: 4 additions & 4 deletions cmd/statshouse/statshouse-tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func mainBenchmarks() {
type packetPrinter struct {
}

func (w *packetPrinter) HandleMetrics(m *tlstatshouse.MetricBytes, cb mapping.MapCallbackFunc) (h data_model.MappedMetricHeader, done bool) {
log.Printf("Parsed metric: %s\n", m.String())
func (w *packetPrinter) HandleMetrics(args data_model.HandlerArgs) (h data_model.MappedMetricHeader, done bool) {
log.Printf("Parsed metric: %s\n", args.MetricBytes.String())
return h, true
}

Expand Down Expand Up @@ -310,12 +310,12 @@ func FakeBenchmarkMetricsPerSecond(listenAddr string) {
// go writeFunc()
serveFunc := func(u *receiver.UDP, rm *atomic.Int64) error {
return u.Serve(receiver.CallbackHandler{
Metrics: func(m *tlstatshouse.MetricBytes, cb mapping.MapCallbackFunc) (h data_model.MappedMetricHeader, done bool) {
Metrics: func(m *tlstatshouse.MetricBytes, cb data_model.MapCallbackFunc) (h data_model.MappedMetricHeader, done bool) {
r := rm.Inc()
if almostReceiveOnly && r%1024 != 0 {
return h, true
}
h, done = mapper.Map(m, metricStorage.GetMetaMetricByNameBytes(m.Name), cb)
h, done = mapper.Map(data_model.HandlerArgs{MetricBytes: m, MapCallback: cb}, metricStorage.GetMetaMetricByNameBytes(m.Name))
if done {
handleMappedMetric(*m, h)
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/statshouse/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ func (w *worker) wait() {
w.mapper.Stop()
}

func (w *worker) HandleMetrics(m *tlstatshouse.MetricBytes, cb mapping.MapCallbackFunc) (h data_model.MappedMetricHeader, done bool) {
func (w *worker) HandleMetrics(args data_model.HandlerArgs) (h data_model.MappedMetricHeader, done bool) {
if w.logPackets != nil {
w.logPackets("Parsed metric: %s\n", m.String())
w.logPackets("Parsed metric: %s\n", args.MetricBytes.String())
}
h, done = w.mapper.Map(m, w.metricStorage.GetMetaMetricByNameBytes(m.Name), cb)
h, done = w.mapper.Map(args, w.metricStorage.GetMetaMetricByNameBytes(args.MetricBytes.Name))
if done {
if w.logPackets != nil {
w.printMetric("cached", *m, h)
w.printMetric("cached", *args.MetricBytes, h)
}
w.sh2.ApplyMetric(*m, h, format.TagValueIDSrcIngestionStatusOKCached)
w.sh2.ApplyMetric(*args.MetricBytes, h, format.TagValueIDSrcIngestionStatusOKCached)
}
return h, done
}
Expand Down
28 changes: 10 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,17 @@ require (

require (
cloud.google.com/go/compute v1.9.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect
github.com/armon/go-metrics v0.3.3 // indirect
github.com/aws/aws-sdk-go v1.44.20 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/dmarkham/enumer v1.5.7 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
Expand All @@ -72,21 +70,22 @@ require (
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/consul/api v1.12.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/go-immutable-radix v1.2.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.9.6 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jackc/puddle/v2 v2.1.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -98,10 +97,11 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand All @@ -122,20 +122,12 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
google.golang.org/grpc v1.50.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.24.0 // indirect
k8s.io/client-go v0.24.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit e6cf0ac

Please sign in to comment.