Skip to content

Commit

Permalink
PromQL
Browse files Browse the repository at this point in the history
Work in progess
Total: 462 / 544 (84.93%) passed, 0 unsupported
  • Loading branch information
alpinskiy committed Feb 16, 2023
1 parent b1738ba commit 98e2932
Show file tree
Hide file tree
Showing 29 changed files with 8,016 additions and 4,881 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ node_modules/
*.tmp
*.swp
*.o

*/**/y.output
13 changes: 0 additions & 13 deletions build/prometheus.yml

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/statshouse-api/statshouse-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ func run(argv args, vkuthPublicKeys map[string][]byte) error {
a.Path("/"+api.EndpointGroup).Methods("POST", "PUT").HandlerFunc(f.HandlePutPostGroup)
a.Path("/" + api.EndpointPrometheus).Methods("GET").HandlerFunc(f.HandleGetPromConfig)
a.Path("/" + api.EndpointPrometheus).Methods("POST").HandlerFunc(f.HandlePostPromConfig)
a.Path("/v1/query").Methods("GET").HandlerFunc(f.HandlePromInstantQuery)
a.Path("/v1/query_range").Methods("GET").HandlerFunc(f.HandlePromRangeQuery)
a.Path("/v1/query").Methods("POST").HandlerFunc(f.HandlePromInstantQuery)
a.Path("/v1/query_range").Methods("POST").HandlerFunc(f.HandlePromRangeQuery)
a.Path("/v1/label/{name}/values").Methods("GET").HandlerFunc(f.HandlePromLabelValuesQuery)
m.PathPrefix("/").Methods("GET", "HEAD").HandlerFunc(f.HandleStatic)

Expand Down
25 changes: 1 addition & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ services:
container_name: sh-agent
user: "root:root"
command: agent -u=root -g=root --cluster=test_shard_aggregator --log-level=trace --agg-addr='aggregator:13336,aggregator:13336,aggregator:13336' --cache-dir=/var/lib/statshouse/cache/agent --remote-write-enabled
expose:
- 8081
ports:
- "8081:8081"
- "13337:13337/udp"
- "13337:13337/tcp"
depends_on:
Expand Down Expand Up @@ -149,29 +148,7 @@ services:
volumes:
- metadata:/var/lib/statshouse/metadata
- kh:/var/lib/clickhouse
grafana:
profiles:
- api-dev
image: grafana/grafana-oss
container_name: grafana
volumes:
- grafana:/var/lib/grafana
expose:
- 3000
network_mode: host
prometheus:
profiles:
- api-dev
image: prom/prometheus
container_name: prometheus
volumes:
- prometheus:/prometheus
- ./build/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

volumes:
kh:
metadata:
prometheus:
grafana:
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/vkcom/statshouse
go 1.19

require (
github.com/ClickHouse/ch-go v0.52.0
github.com/ClickHouse/clickhouse-go/v2 v2.4.2
github.com/cloudflare/tableflip v1.2.3
github.com/dchest/siphash v1.2.3
Expand All @@ -18,7 +19,6 @@ require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/grafana/grafana-plugin-sdk-go v0.144.0
github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2
github.com/hrissan/tdigest v0.0.2
github.com/jmoiron/sqlx v1.3.5
github.com/mailru/easyjson v0.7.7
Expand All @@ -30,10 +30,12 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
github.com/tinylib/msgp v1.1.6
github.com/vkcom/statshouse-go v0.0.0-20221129160158-005f723138d1
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go.uber.org/atomic v1.10.0
go.uber.org/multierr v1.9.0
go4.org/mem v0.0.0-20220726221520-4f986261bf13
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75
golang.org/x/net v0.5.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.4.0
Expand All @@ -47,7 +49,6 @@ require (

require (
cloud.google.com/go/compute v1.9.0 // indirect
github.com/ClickHouse/ch-go v0.52.0 // 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
Expand All @@ -68,6 +69,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // 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/go-hclog v0.14.1 // indirect
Expand Down Expand Up @@ -102,7 +104,6 @@ require (
github.com/prometheus/procfs v0.9.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/vkcom/statshouse-go v0.0.0-20221129160158-005f723138d1 // indirect
go.opentelemetry.io/otel v1.12.0 // indirect
go.opentelemetry.io/otel/metric v0.35.0 // indirect
go.opentelemetry.io/otel/trace v1.12.0 // indirect
Expand Down
65 changes: 4 additions & 61 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/vkcom/statshouse/internal/format"
"github.com/vkcom/statshouse/internal/metajournal"
"github.com/vkcom/statshouse/internal/pcache"
"github.com/vkcom/statshouse/internal/promql"
"github.com/vkcom/statshouse/internal/util"
"github.com/vkcom/statshouse/internal/vkgo/srvfunc"
"github.com/vkcom/statshouse/internal/vkgo/statlogs"
Expand Down Expand Up @@ -163,6 +164,7 @@ type (
readOnly bool
rUsage syscall.Rusage // accessed without lock by first shard addBuiltIns
rmID int
promEngine promql.Engine
}

//easyjson:json
Expand Down Expand Up @@ -447,6 +449,7 @@ func NewHandler(verbose bool, staticDir fs.FS, jsSettings JSSettings, protectedP
writeActiveQuieries(chV2, "2")
})

h.promEngine = promql.NewEngine(h, h, h.location)
return h, nil
}

Expand Down
Loading

0 comments on commit 98e2932

Please sign in to comment.