return entries;
}
+static StatsMap toCPUStatsMap(const string& name)
+{
+ const string pbasename = getPrometheusName(name);
+ StatsMap entries;
+
+ for (unsigned int n = 0; n < g_numThreads; ++n) {
+ uint64_t tm = doGetThreadCPUMsec(n);
+ std::string pname = pbasename + "{thread=" + std::to_string(n) + '}';
+ entries.emplace(make_pair(name + "-thread-" + std::to_string(n), StatsMapEntry{pname, std::to_string(tm)}));
+ }
+ return entries;
+}
+
extern ResponseStats g_rs;
static void registerAllStats1()
addGetStat("cpu-steal", []{ return getCPUSteal(string()); });
#endif
- for (unsigned int n = 0; n < g_numThreads; ++n) {
- addGetStat("cpu-msec-thread-" + std::to_string(n), [n]{ return doGetThreadCPUMsec(n);});
- }
+ addGetStat("cpu-msec", []() { return toCPUStatsMap("cpu-msec"); });
#ifdef MALLOC_TRACE
addGetStat("memory-allocs", []{ return g_mtracer->getAllocs(string()); });
if (prometheusTypeName.empty()) {
continue;
}
- if (metricDetails.prometheusType == PrometheusMetricType::histogram) {
+ if (metricDetails.prometheusType == PrometheusMetricType::multicounter) {
+ string shortname = prometheusMetricName.substr(0, prometheusMetricName.find('{'));
+ output << "# HELP " << shortname << " " << metricDetails.description << "\n";
+ output << "# TYPE " << shortname << " " << "counter" << "\n";
+ }
+ else if (metricDetails.prometheusType == PrometheusMetricType::histogram) {
// name is XXX_count, strip the _count part
- prometheusMetricName = prometheusMetricName.substr(0, prometheusMetricName.length() - 6);
+ string shortname = prometheusMetricName.substr(0, prometheusMetricName.length() - 6);
+ output << "# HELP " << shortname << " " << metricDetails.description << "\n";
+ output << "# TYPE " << shortname << " " << prometheusTypeName << "\n";
+ } else {
+ // for these we have the help and types encoded in the sources:
output << "# HELP " << prometheusMetricName << " " << metricDetails.description << "\n";
output << "# TYPE " << prometheusMetricName << " " << prometheusTypeName << "\n";
- continue;
}
- // for these we have the help and types encoded in the sources:
- output << "# HELP " << prometheusMetricName << " " << metricDetails.description << "\n";
- output << "# TYPE " << prometheusMetricName << " " << prometheusTypeName << "\n";
}
output << prometheusMetricName << " " << tup.second.d_value << "\n";
}
{"concurrent-queries",
MetricDefinition(PrometheusMetricType::gauge,
"Number of MThreads currently running")},
+
+ // For multicounters, state the first
{"cpu-msec-thread-0",
- MetricDefinition(PrometheusMetricType::counter,
+ MetricDefinition(PrometheusMetricType::multicounter,
"Number of milliseconds spent in thread n")},
+
{"dnssec-authentic-data-queries",
MetricDefinition(PrometheusMetricType::counter,
"Number of queries received with the AD bit set")},
{ "dns64-prefix-answers",
MetricDefinition(PrometheusMetricType::counter,
"Number of AAAA and PTR generated by a matching dns64-prefix")},
+ { "aggressive-nsec-cache-entries",
+ MetricDefinition(PrometheusMetricType::counter,
+ "Number of entries in the aggressive NSEC cache")},
+
+ { "aggressive-nsec-cache-nsec-hits",
+ MetricDefinition(PrometheusMetricType::counter,
+ "Number of NSEC-related hits from the aggressive NSEC cache")},
+
+ { "aggressive-nsec-cache-nsec-wc-hits",
+ MetricDefinition(PrometheusMetricType::counter,
+ "Number of answers synthesized from the NSEC aggressive cache")},
+
+ { "aggressive-nsec-cache-nsec3-hits",
+ MetricDefinition(PrometheusMetricType::counter,
+ "Number of NSEC3-related hits from the aggressive NSEC cache")},
+
+ { "aggressive-nsec-cache-nsec3-wc-hits",
+ MetricDefinition(PrometheusMetricType::counter,
+ "Number of answers synthesized from the NSEC3 aggressive cache")},
// For cumulative histogram, state the xxx_count name where xxx matches the name in rec_channel_rec
{ "cumul-answers-count",
auto varmap = getAllStatsMap(StatComponent::API);
for (const auto& tup : varmap) {
std::string metricName = tup.first;
- if (metricName.find("cpu-msec-") == 0) {
+ if (metricName.find("cpu-msec-") == 0) {
+ continue;
+ }
+ if (metricName.find("cumul-") == 0) {
continue;
}
MetricDefinition metricDetails;