MCPcopy Index your code
hub / github.com/cloudflare/parquet-tsdb-poc

github.com/cloudflare/parquet-tsdb-poc @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
435 symbols 1,027 edges 35 files 19 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

parquet-tsdb-poc

POC for a parquet based TSDB in object storage.

Why

This project was inspired by this excellent talk by Shopify's Filip Petkovski. It is an attempt to build a service that can convert Prometheus TSDB blocks into parquet files and serve PromQL queries to backfill a Thanos deployment.

Developing

We recommend to use nix to fulfill all development dependencies. Visit Nix Download to get started. To activate the development environment simply run nix-shell in the project root.

  • to build the binary run nix-shell --run 'make build'
  • to run tests run nix-shell --run 'make test'

Running

Server

Once built, you can run the server using something like:

parquet-gateway serve \
    --storage.prefix my-prefix \
    --http.internal.port=6060 \
    --http.prometheus.port=9090 \
    --http.thanos.port=9091 \
    --block.syncer.interval=30m \
    --block.syncer.concurrency=32 \
    --block.discovery.interval=30m \
    --block.discovery.concurrency=32 \
    --query.external-label=prometheus=my-prometheus \
    --query.external-label=replica=ha-1

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

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

curl 'http://0.0.0.0:9000/api/v1/query' \
  -sq \
  -H 'content-type: application/x-www-form-urlencoded' \
  --data-urlencode 'query=vector(1)' | jq
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {},
        "value": [
          1741267893.103,
          "1"
        ]
      }
    ]
  }
}

Converter

To convert TSDB blocks in the .data/source directory that overlap 09/2021 and write the resulting parquet files into the .data/destination directory.

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

Extension points exported contracts — how you extend this code

Constraint (Interface)
(no doc) [6 implementers]
search/search.go
MetaFilter (Interface)
(no doc) [3 implementers]
db/syncer.go
Convertible (Interface)
(no doc)
convert/convert.go
QueryAPIOption (FuncType)
(no doc)
api/http/query.go
DBOption (FuncType)
(no doc)
db/db.go
DiscoveryOption (FuncType)
(no doc)
db/discover.go
RowReaderCloser (Interface)
(no doc)
search/search.go
SyncerOption (FuncType)
(no doc)
db/syncer.go

Core symbols most depended-on inside this repo

writeErrorResponse
called by 35
api/http/query.go
Close
called by 25
db/db.go
Info
called by 21
api/grpc/thanos.go
Schema
called by 8
search/search.go
Seek
called by 8
db/iterator.go
BeginOfDay
called by 7
internal/util/date.go
parseTimeParam
called by 7
api/http/query.go
LabelNameToColumn
called by 7
schema/schema.go

Shape

Method 199
Function 142
Struct 78
FuncType 8
Interface 6
TypeAlias 2

Languages

Go100%

Modules by API surface

search/search.go35 symbols
search/constraint.go33 symbols
convert/convert.go30 symbols
db/syncer.go29 symbols
db/iterator.go29 symbols
api/http/query.go27 symbols
convert/sort.go25 symbols
db/seriesset.go23 symbols
proto/metapb/meta.pb.go21 symbols
cmd/serve.go21 symbols
db/db.go19 symbols
db/shard.go17 symbols

For agents

$ claude mcp add parquet-tsdb-poc \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page