summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4161e32)
raw | patch | inline | side by side (parent: 4161e32)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 24 Sep 2017 14:00:53 +0000 (21:00 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 24 Sep 2017 14:14:04 +0000 (21:14 +0700) |
When several distributions needs to be calculated in one 'tail' instance,
all their metrics will be reported as single 'bucket' type with the same plugin instance value.
That is confusing and this patch allows to split these metrics to their own types.
all their metrics will be reported as single 'bucket' type with the same plugin instance value.
That is confusing and this patch allows to split these metrics to their own types.
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index a35fb732b48f883de92e1fb0977c409562861a7a..a0e342ea832569886e8ed5a8d900ed61718ec4f8 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Bucket 0.5 1.0 # -> bucket-latency-foo-0.5_1
# Bucket 1.0 2.0 # -> bucket-latency-foo-1_2
# Bucket 2.0 0 # -> bucket-latency-foo-2_inf
+# #BucketType "bucket"
# </DSType>
# Type "latency"
# Instance "foo"
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 4b0ddee79247f7e6e9566221b13aa8d33ca063bb..3be5d4b8edf8025a2e609920741ab19dadc5b6eb 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
<DSType "Distribution">
Percentile 99
Bucket 0 100
+ #BucketType "bucket"
</DSType>
Type "latency"
Instance "foo"
<DSType "Distribution">
Percentile 99
Bucket 0 100
+ BucketType "bucket"
</DSType>
=over 4
Bucket 20 50
Bucket 50 0
-Metrics are reported with the I<type> C<bucket> and the I<type instance>
+Metrics are reported with the I<type> set by B<BucketType> option (C<bucket>
+by default) and the I<type instance>
C<E<lt>TypeE<gt>[-E<lt>InstanceE<gt>]-E<lt>lower_boundE<gt>_E<lt>upper_boundE<gt>>.
This option may be repeated to calculate more than one rate.
+=item B<BucketType> I<Type>
+
+Sets the type used to dispatch B<Bucket> metrics.
+Optional, by default C<bucket> will be used.
+
=back
=back
index 0f8c2a269e088b6c97800b87019f1876028b8a32..5eb5b6d9697265a1ef3fd0737170fd36fa993a8c 100644 (file)
status = latency_config_add_percentile(conf, child, plugin);
else if (strcasecmp("Bucket", child->key) == 0)
status = latency_config_add_bucket(conf, child, plugin);
+ else if (strcasecmp("BucketType", child->key) == 0)
+ status = cf_util_get_string(child, &conf->bucket_type);
else
WARNING("%s plugin: \"%s\" is not a valid option within a \"%s\" block.",
plugin, child->key, ci->key);
return ENOMEM;
}
+ if (src.bucket_type != NULL) {
+ dst->bucket_type = strdup(src.bucket_type);
+ if (dst->bucket_type == NULL) {
+ latency_config_free(*dst);
+ return ENOMEM;
+ }
+ }
+
memmove(dst->percentile, src.percentile,
dst->percentile_num * sizeof(*dst->percentile));
memmove(dst->buckets, src.buckets, dst->buckets_num * sizeof(*dst->buckets));
void latency_config_free(latency_config_t conf) {
sfree(conf.percentile);
sfree(conf.buckets);
+ sfree(conf.bucket_type);
} /* void latency_config_free */
index 9a7a11af985c315729be27e57d9160827945c464..7008fd000bfe5512f38c7ad7abe81400058c5b07 100644 (file)
latency_bucket_t *buckets;
size_t buckets_num;
+ char *bucket_type;
/*
_Bool lower;
diff --git a/src/utils_tail_match.c b/src/utils_tail_match.c
index 242cc384149231458323b4974879c87e087e3cc7..65655dcd12b7b57aefb9070a87c242a394ecc898 100644 (file)
--- a/src/utils_tail_match.c
+++ b/src/utils_tail_match.c
}
/* Submit buckets */
- sstrncpy(vl.type, "bucket", sizeof(vl.type));
+ if (data->latency_config.bucket_type != NULL)
+ sstrncpy(vl.type, data->latency_config.bucket_type, sizeof(vl.type));
+ else
+ sstrncpy(vl.type, "bucket", sizeof(vl.type));
+
for (size_t i = 0; i < data->latency_config.buckets_num; i++) {
latency_bucket_t bucket = data->latency_config.buckets[i];