Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
parquet-gateway
.cover
.blocks
.data
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
.PHONY: all build proto lint test
.PHONY: all ci build proto lint test-norace test deps

all: build

build: proto parquet-gateway
ci: test-norace build lint

build: protos parquet-gateway

GO = go
GOIMPORTS = goimports
REVIVE = revive
GOTOOL = $(GO) tool -modfile=go.tools.mod
GOIMPORTS = $(GOTOOL) golang.org/x/tools/cmd/goimports
REVIVE = $(GOTOOL) github.com/mgechev/revive
MODERNIZE = $(GOTOOL) golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize
PROTOC = protoc

lint: $(wildcard **/*.go)
@echo ">> running lint..."
@$(REVIVE) -config revive.toml ./...
$(REVIVE) -config revive.toml ./...
$(MODERNIZE) -test ./...
find . -name '*.go' ! -path './proto/*' | xargs $(GOIMPORTS) -l -w -local $(head -n 1 go.mod | cut -d ' ' -f 2)

test-norace: $(wildcard **/*.go)
@echo ">> running tests without checking for races..."
@mkdir -p .cover
$(GO) test -v -tags stringlabels -short -count=1 ./... -coverprofile .cover/cover.out

test: $(wildcard **/*.go)
@echo ">> running tests..."
@mkdir -p .cover
$(GO) test -v -race -count=1 ./... -coverprofile .cover/cover.out
$(GO) test -v -tags stringlabels -race -short -count=1 ./... -coverprofile .cover/cover.out

parquet-gateway: $(wildcard **/*.go)
parquet-gateway: $(shell find . -type f -name '*.go')
@echo ">> building binaries..."
@$(GO) build -o parquet-gateway github.com/cloudflare/parquet-tsdb-poc/cmd
@$(GO) build -tags stringlabels -o parquet-gateway github.com/cloudflare/parquet-tsdb-poc/cmd

proto: proto/metapb/meta.pb.go
protos: proto/metapb/meta.pb.go

proto/metapb/meta.pb.go: proto/metapb/meta.proto
@echo ">> compiling protos..."
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This will:
- load blocks from the `.data/my-prefix` directory
- expose internal metrics and readiness handlers on port 6060
- expose a subset of the Prometheus HTTP API on port 9090
- expose an Thanos Info and Query gRPC service on port 9091
- expose an Thanos Info, Series and Query gRPC service on port 9091

You can now query it by pointing a Thanos Querier at it or through curl:

Expand Down Expand Up @@ -73,6 +73,10 @@ To convert TSDB blocks in the `.data/source` directory that overlap `09/2021` an
parquet-gateway convert \
--tsdb.storage.prefix source \
--parquet.storage.prefix destination \
--convert.start=2021-09-01T00:00:00Z \
--convert.end=2021-10-01T00:00:00Z
--convert.sorting.label=__name__ \
--convert.sorting.label=namespace
```

## Note

The code has significant overlap with the work in "https://github.com/prometheus-community/parquet-common". We are in the process of upstreaming and eventually plan to use it as a library.
28 changes: 28 additions & 0 deletions api/grpc/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

package grpc

import (
"errors"

grpc_prom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
"github.com/prometheus/client_golang/prometheus"
)

var (
ServerMetrics = grpc_prom.NewServerMetrics(
grpc_prom.WithServerHandlingTimeHistogram(
grpc_prom.WithHistogramOpts(&prometheus.HistogramOpts{
Buckets: prometheus.ExponentialBucketsRange(0.1, 30, 20),
}),
),
)
)

func RegisterMetrics(reg prometheus.Registerer) error {
return errors.Join(
reg.Register(ServerMetrics),
)
}
Loading