src/daemon/utils_cache.c: Don't overwrite the meta data of existing entries.
The cache entry's meta data is not the same as the metric's meta data.
Overwriting the cache entry's meta data breaks a number of plugins,
including the network and write_stackdriver plugins.
daemon: Create the metric_family_t and metric_t types.
A "metric family" is a set of metrics, all with the same name (but
different labels and/or label values). The identity is split between the
two types: the "metric family" holds the "name" while the "metric" holds
the labels. Likewise, the "metric family" holds the metric type, the
"metric" holds the metric value.
This commit contains all required changes to compile the daemon, but
pretty much everything else still fails to build. The tests have not yet
updated either.
* Rename variables to fit the naming schema better.
* Improve the error message. value_to_metric() can and has failed for
other reasons than out of memory.
Florian Forster [Wed, 24 Jun 2020 20:06:11 +0000 (22:06 +0200)]
src/daemon/plugin.[ch]: Ensure that "time" and "interval" are set at enqueue time.
This also ensures that an "instance" label (as used by the Prometheus
collectd exporter) exists. This is currently essentially a placeholder
for target labels.
* Struct "metric_t": unnecessary fields "type", "plugin", "ds" have
been removed. The field "value_ds_type" has been renamed to
"value_type".
* The reference counted, multiple instance "meta_data_list_head_t" type
has been removed. Manually doing the reference counting all over the
place is error prone and it seems like premature optimization.
* The "<type>_destroy" functions must handle NULL gracefully. Removed
NULL-checks around their invocation to improve readability.
daemon: Reworked some code in src/daemon/plugin.[ch].
Unfortunately it's all a bit messy and entangled. Since this is such
an early WIP, I didn't spend the (substantial) time needed to pick this
into separate changes. The changes in this commit are:
* Create a consistent naming schema for the identity functions:
* Rename "create_identity" to "identity_create_legacy".
* Rename "clone_identity" to "identity_clone".
* Rename "destroy_identity" to "identity_destroy".
* Add "identity_create" to allocate a new identity_t.
* Copy key and value strings within "identity_add_label".
* Make use of "identity_create" and "identity_add_label" in
"identity_clone", "identity_create_legacy" and others that used
to fiddle with the AVL tree directly.
* Remove the "_p" suffix used for pointers. This is quite unusual for
the collectd codebase.
This commit is where the major transform takes palce; the internal
representation is changed, and the read plugins use that indirectly
when they submit a value list transparently.
The baromerter read plugin has been converted to using metric_t
representation natively.
The write plugins have to be adapted to use these new single data
source metrics.
[metric-label-support]: Modify write queue to use metric_t
This commit adds an updated write queue data structure, and updates
the enqueue and dequeue calling paths. Note that while this compiles
and the tests pass, thisis not a functioning collectd by itself, the
caching and networking code is a work in progress.
Manoj Srivastava [Wed, 20 Nov 2019 18:03:40 +0000 (10:03 -0800)]
[metric-label-support]: Utility to convert value_list_t to metric_t
This is another step in implementing the proposal defined in the
document "Adding Labels to Collectd Metrics"
- https://docs.google.com/document/d/173gGP3tUD3yfN2NNHxCv0BsKsacfDlSyoaQIn7MqLtQ/edit?usp=sharing
This commit adds a utility method to convert from the old metric
represetation to a the new datastructures updated as per the document:
"Compare data structures for metric labels (collectd)"
- https://docs.google.com/document/d/1RZ7YAO6lWcDDvevzxFGVDgv4UQpdgWoT7OCP9Vpb2CU/edit?usp=sharing
This method is designed to be called from plugindispatch_values during
the transition period before read plugins are amended to use the
metric_t data structure directly.
This commit adds no change in behaviour or functionality, but cleans
up a few diagnostic, updates the metrics_t data structure to add
names of the type and subtype, and fixes a space/tab anpmaly.. The
tests still work.
This is the initial commit on the proposal defined in the document
"Adding Labels to Collectd Metrics"
- https://docs.google.com/document/d/173gGP3tUD3yfN2NNHxCv0BsKsacfDlSyoaQIn7MqLtQ/edit?usp=sharing
With the datastructures updated as per the document:
"Compare data structures for metric labels (collectd)"
- https://docs.google.com/document/d/1RZ7YAO6lWcDDvevzxFGVDgv4UQpdgWoT7OCP9Vpb2CU/edit?usp=sharing
This commit adds the initial declaration and definition of the basic
data structure, and sets up the build system to add in unit testing
for the label store, the identity and metrics data streuctures.
Florian Forster [Sun, 21 Jun 2020 16:33:58 +0000 (18:33 +0200)]
src/daemon/metric.[ch]: Data types and functions representing metrics.
This implementation closely mirrors the Prometheus / OpenMetrics
protocol buffer.
A "metric family" is a set of metrics, all with the same name (but
different labels and/or label values). The identity is split between the
two types: the "metric family" holds the "name" while the "metric" holds
the labels. Likewise, the "metric family" holds the metric type, the
"metric" holds the metric value.
This commit contains all required changes to compile the daemon, but
pretty much everything else still fails to build. The tests have not yet
updated either.
The metric_marshal_text() function uses a strbuf_t* and generates the
OpenMetric exposition format.
Florian Forster [Sun, 21 Jun 2020 16:33:58 +0000 (18:33 +0200)]
src/daemon/metric.[ch]: Data types and functions representing metrics.
This implementation closely mirrors the Prometheus / OpenMetrics
protocol buffer.
A "metric family" is a set of metrics, all with the same name (but
different labels and/or label values). The identity is split between the
two types: the "metric family" holds the "name" while the "metric" holds
the labels. Likewise, the "metric family" holds the metric type, the
"metric" holds the metric value.
This commit contains all required changes to compile the daemon, but
pretty much everything else still fails to build. The tests have not yet
updated either.
Florian Forster [Fri, 19 Jun 2020 08:14:53 +0000 (10:14 +0200)]
strbuf: Add STRBUF_CREATE_FIXED, unify naming.
This changes the macro and function name to use "fixed" when a buffer and
its size are provided, and "static" if `sizeof()` is used to determine the
size.
The macros now return and expect a `strbuf_t`, i.e. *not* a pointer. This
makes it easier to see that the buffer is allocated on the stack and may
go out of scope.
The buffer size in the tests has been changed to 9, so that `sizeof(array)`
and `sizeof(pointer)` return different values.
After losing our connection to a MQTT broker our subscription will be gone,
too, so we need to subscribe to our topic once again after reconnecting,
otherwise collectd will not receive any MQTT messages anymore.
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Provide an udev rule with ID_SERIAL based, disk plugin usable ID attribute
Disk plugin UdevNameAttr option is very useful for making sure that the
same disk always ends in the same RRD file no matter which particular
device node it ends being assigned by the OS.
However, using the most fitting ID_SERIAL udev attribute for this purpose
results in data about the whole disk and each partition being mixed
together incorrectly, since this attribute has exactly the same value for
the whole disk device node and its particular partition nodes.
Let's introduce an ID_COLLECTD attribute instead which differentiates
between the whole disk and its particular partitions in a new udev rule
file provided in "contrib" directory.
To warn users about the issue let's also add a relevant note to the
UdevNameAttr option description.
Based on Stewart Adam's workaround from
https://github.com/collectd/collectd/issues/823
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>