Don't include endpoint label/value when collecting metrics internally

This commit is contained in:
Tim Wojtulewicz 2024-03-12 14:17:36 -07:00
parent 5c20d81a6a
commit 5c17e43a1d
4 changed files with 15 additions and 7 deletions

View file

@ -143,8 +143,11 @@ public:
std::vector<RecordValPtr> records; std::vector<RecordValPtr> records;
for ( const auto& ctr : counters ) { for ( const auto& ctr : counters ) {
auto label_values_vec = make_intrusive<VectorVal>(string_vec_type); auto label_values_vec = make_intrusive<VectorVal>(string_vec_type);
for ( const auto& [label_key, label] : ctr->Labels() ) for ( const auto& [label_key, label] : ctr->Labels() ) {
// We don't include the endpoint key/value unless it's a prometheus request
if ( label_key != "endpoint" )
label_values_vec->Append(make_intrusive<StringVal>(label)); label_values_vec->Append(make_intrusive<StringVal>(label));
}
auto r = make_intrusive<zeek::RecordVal>(metric_record_type); auto r = make_intrusive<zeek::RecordVal>(metric_record_type);
r->Assign(labels_idx, label_values_vec); r->Assign(labels_idx, label_values_vec);

View file

@ -167,8 +167,11 @@ public:
std::vector<RecordValPtr> records; std::vector<RecordValPtr> records;
for ( const auto& g : gauges ) { for ( const auto& g : gauges ) {
auto label_values_vec = make_intrusive<VectorVal>(string_vec_type); auto label_values_vec = make_intrusive<VectorVal>(string_vec_type);
for ( const auto& [label_key, label] : g->Labels() ) for ( const auto& [label_key, label] : g->Labels() ) {
// We don't include the endpoint key/value unless it's a prometheus request
if ( label_key != "endpoint" )
label_values_vec->Append(make_intrusive<StringVal>(label)); label_values_vec->Append(make_intrusive<StringVal>(label));
}
auto r = make_intrusive<zeek::RecordVal>(metric_record_type); auto r = make_intrusive<zeek::RecordVal>(metric_record_type);
r->Assign(labels_idx, label_values_vec); r->Assign(labels_idx, label_values_vec);

View file

@ -144,8 +144,11 @@ public:
std::vector<RecordValPtr> records; std::vector<RecordValPtr> records;
for ( const auto& h : histograms ) { for ( const auto& h : histograms ) {
auto label_values_vec = make_intrusive<VectorVal>(string_vec_type); auto label_values_vec = make_intrusive<VectorVal>(string_vec_type);
for ( const auto& [label_key, label] : h->Labels() ) for ( const auto& [label_key, label] : h->Labels() ) {
// We don't include the endpoint key/value unless it's a prometheus request
if ( label_key != "endpoint" )
label_values_vec->Append(make_intrusive<StringVal>(label)); label_values_vec->Append(make_intrusive<StringVal>(label));
}
auto r = make_intrusive<zeek::RecordVal>(histogram_metric_type); auto r = make_intrusive<zeek::RecordVal>(histogram_metric_type);
r->Assign(labels_idx, label_values_vec); r->Assign(labels_idx, label_values_vec);

View file

@ -42,7 +42,6 @@ RecordValPtr MetricFamily::GetMetricOptsRecord() const {
record_val->Assign(is_total_idx, val_mgr->Bool(is_sum)); record_val->Assign(is_total_idx, val_mgr->Bool(is_sum));
auto label_names_vec = make_intrusive<zeek::VectorVal>(string_vec_type); auto label_names_vec = make_intrusive<zeek::VectorVal>(string_vec_type);
label_names_vec->Append(make_intrusive<StringVal>("endpoint"));
for ( const auto& lbl : labels ) for ( const auto& lbl : labels )
label_names_vec->Append(make_intrusive<StringVal>(lbl)); label_names_vec->Append(make_intrusive<StringVal>(lbl));