Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#draft proto2 fails to push into grafana cloud #488

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ travis-ci = { repository = "pingcap/rust-prometheus" }
features = ["nightly"]

[features]
default = ["protobuf"]
default = ["protobuf", "gen", "push"]
gen = ["protobuf-codegen-pure"]
nightly = ["libc"]
process = ["libc", "procfs"]
push = ["reqwest", "libc", "protobuf"]
push = ["reqwest", "libc", "protobuf", "snap"]

[dependencies]
cfg-if = "^1.0"
Expand All @@ -31,6 +31,7 @@ lazy_static = "^1.4"
libc = { version = "^0.2", optional = true }
parking_lot = "^0.12"
protobuf = { version = "^2.0", optional = true }
snap = { version = "^1.1", optional = true }
memchr = "^2.3"
reqwest = { version = "^0.11", features = ["blocking"], optional = true }
thiserror = "^1.0"
Expand Down
87 changes: 75 additions & 12 deletions proto/proto_model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,37 @@ syntax = "proto2";

package io.prometheus.client;
option java_package = "io.prometheus.client";
option go_package = "github.com/prometheus/client_model/go;io_prometheus_client";

import "google/protobuf/timestamp.proto";

message LabelPair {
optional string name = 1;
optional string value = 2;
}

enum MetricType {
COUNTER = 0;
GAUGE = 1;
SUMMARY = 2;
UNTYPED = 3;
HISTOGRAM = 4;
// COUNTER must use the Metric field "counter".
COUNTER = 0;
// GAUGE must use the Metric field "gauge".
GAUGE = 1;
// SUMMARY must use the Metric field "summary".
SUMMARY = 2;
// UNTYPED must use the Metric field "untyped".
UNTYPED = 3;
// HISTOGRAM must use the Metric field "histogram".
HISTOGRAM = 4;
// GAUGE_HISTOGRAM must use the Metric field "histogram".
GAUGE_HISTOGRAM = 5;
}

message Gauge {
optional double value = 1;
}

message Counter {
optional double value = 1;
optional double value = 1;
optional Exemplar exemplar = 2;
}

message Quantile {
Expand All @@ -53,14 +64,66 @@ message Untyped {
}

message Histogram {
optional uint64 sample_count = 1;
optional double sample_sum = 2;
repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional.
optional uint64 sample_count = 1;
optional double sample_count_float = 4; // Overrides sample_count if > 0.
optional double sample_sum = 2;
// Buckets for the conventional histogram.
repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional.

// Everything below here is for native histograms (also known as sparse histograms).
// Native histograms are an experimental feature without stability guarantees.

// schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8.
// They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and
// then each power of two is divided into 2^n logarithmic buckets.
// Or in other words, each bucket boundary is the previous boundary times 2^(2^-n).
// In the future, more bucket schemas may be added using numbers < -4 or > 8.
optional sint32 schema = 5;
optional double zero_threshold = 6; // Breadth of the zero bucket.
optional uint64 zero_count = 7; // Count in zero bucket.
optional double zero_count_float = 8; // Overrides sb_zero_count if > 0.

// Negative buckets for the native histogram.
repeated BucketSpan negative_span = 9;
// Use either "negative_delta" or "negative_count", the former for
// regular histograms with integer counts, the latter for float
// histograms.
repeated sint64 negative_delta = 10; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
repeated double negative_count = 11; // Absolute count of each bucket.

// Positive buckets for the native histogram.
repeated BucketSpan positive_span = 12;
// Use either "positive_delta" or "positive_count", the former for
// regular histograms with integer counts, the latter for float
// histograms.
repeated sint64 positive_delta = 13; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
repeated double positive_count = 14; // Absolute count of each bucket.
}

// A Bucket of a conventional histogram, each of which is treated as
// an individual counter-like time series by Prometheus.
message Bucket {
optional uint64 cumulative_count = 1; // Cumulative in increasing order.
optional double upper_bound = 2; // Inclusive.
optional uint64 cumulative_count = 1; // Cumulative in increasing order.
optional double cumulative_count_float = 4; // Overrides cumulative_count if > 0.
optional double upper_bound = 2; // Inclusive.
optional Exemplar exemplar = 3;
}

// A BucketSpan defines a number of consecutive buckets in a native
// histogram with their offset. Logically, it would be more
// straightforward to include the bucket counts in the Span. However,
// the protobuf representation is more compact in the way the data is
// structured here (with all the buckets in a single array separate
// from the Spans).
message BucketSpan {
optional sint32 offset = 1; // Gap to previous span, or starting point for 1st span (which can be negative).
optional uint32 length = 2; // Length of consecutive buckets.
}

message Exemplar {
repeated LabelPair label = 1;
optional double value = 2;
optional google.protobuf.Timestamp timestamp = 3; // OpenMetrics-style.
}

message Metric {
Expand All @@ -78,4 +141,4 @@ message MetricFamily {
optional string help = 2;
optional MetricType type = 3;
repeated Metric metric = 4;
}
}