diff options
| author | fumingwei <[email protected]> | 2023-09-11 16:59:48 +0800 |
|---|---|---|
| committer | fumingwei <[email protected]> | 2023-09-11 16:59:48 +0800 |
| commit | c8221fb80387230443727687d4425473327ba978 (patch) | |
| tree | d4b733416e14d7e13582c72977caeb6c04dfa923 /src/exporter/prometheus_exporter.c | |
| parent | 159c7767eb6380dad96dc50fd9b7af54b6b8efb7 (diff) | |
temp 10feature-fs4
Diffstat (limited to 'src/exporter/prometheus_exporter.c')
| -rw-r--r-- | src/exporter/prometheus_exporter.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/exporter/prometheus_exporter.c b/src/exporter/prometheus_exporter.c index 4ccb587..741c4b8 100644 --- a/src/exporter/prometheus_exporter.c +++ b/src/exporter/prometheus_exporter.c @@ -312,44 +312,44 @@ static int build_fieldstat_exporter_payload(struct fieldstat_exporter *exporter, double hll_value = 0.0; char cell_buf[512] = {0}; //part of one metric - build_cell_tags_buf(tags_list->tag, tags_list->n_tag, cell_buf, sizeof(cell_buf)); + build_cell_tags_buf(tags_list[k].tag, tags_list[k].n_tag, cell_buf, sizeof(cell_buf)); payload_realloc(&buf, &size, offset); switch(metric_type) { - case METRIC_TYPE_COUNTER: - value = fieldstat_counter_get(instance, i, j, k); - offset += snprintf(buf + offset, size - offset, "%s{%s%s%s} %lld\n", - name_buf, global_buf, cube_buf, cell_buf, value); - break; - - case METRIC_TYPE_HLL: - hll_value = fieldstat_hll_get(instance, i, j, k); - offset += snprintf(buf + offset, size - offset, "%s_total_count{%s%s%s} %.0f\n", - name_buf, global_buf, cube_buf, cell_buf, hll_value); - break; - - case METRIC_TYPE_HISTOGRAM: + case METRIC_TYPE_COUNTER: + value = fieldstat_counter_get(instance, cube_ids[i], j, k); + offset += snprintf(buf + offset, size - offset, "%s{%s%s%s} %lld\n", + name_buf, global_buf, cube_buf, cell_buf, value); + break; + + case METRIC_TYPE_HLL: + hll_value = fieldstat_hll_get(instance, cube_ids[i], j, k); + offset += snprintf(buf + offset, size - offset, "%s_total_count{%s%s%s} %.0f\n", + name_buf, global_buf, cube_buf, cell_buf, hll_value); + break; + + case METRIC_TYPE_HISTOGRAM: + + for(int m = 0; m < sizeof(quantiles)/sizeof(quantiles[0]); m++) + { + value = fieldstat_hist_value_at_percentile(instance, cube_ids[i], j, k, quantiles[m] * 100); + offset += snprintf(buf + offset, size - offset, + "%s{%s%s%s,quantile=\"%0.2f\"} %lld\n", + name_buf, global_buf, cube_buf, cell_buf, quantiles[m], value); + } + + value = fieldstat_hist_value_total_count(instance, cube_ids[i], j, k); + offset += snprintf(buf + offset, size - offset, "%s_count{%s%s%s} %lld\n", + name_buf, global_buf, cube_buf, cell_buf, value); - for(int m = 0; m < sizeof(quantiles)/sizeof(quantiles[0]); m++) - { - value = fieldstat_hist_value_at_percentile(instance, i, j, k, quantiles[m] * 100); - offset += snprintf(buf + offset, size - offset, - "%s{%s%s%s,quantile=\"%0.2f\"} %lld\n", - name_buf, global_buf, cube_buf, cell_buf, quantiles[m], value); - } - - value = fieldstat_hist_value_total_count(instance, i, j, k); - offset += snprintf(buf + offset, size - offset, "%s_count{%s%s%s} %lld\n", - name_buf, global_buf, cube_buf, cell_buf, value); - - value = fieldstat_hist_value_sum(instance, i, j, k); - offset += snprintf(buf + offset, size - offset, "%s_sum{%s%s%s} %lld\n", - name_buf, global_buf, cube_buf, cell_buf, value); - break; - default: - assert(0); - break; + value = fieldstat_hist_value_sum(instance, cube_ids[i], j, k); + offset += snprintf(buf + offset, size - offset, "%s_sum{%s%s%s} %lld\n", + name_buf, global_buf, cube_buf, cell_buf, value); + break; + default: + assert(0); + break; } } |
