Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Message processor #118

Merged
merged 17 commits into from
Dec 11, 2024
Merged

New Message processor #118

merged 17 commits into from
Dec 11, 2024

Conversation

TomTheBear
Copy link
Member

New message processor using expr instead of gval

Can be integrated anywhere to check:

  • drop messages by name, message type or condition
  • rename messages by name or condition
  • move entries between tags, meta and fields based on a condition
  • add tag, meta or field entries based on a condition
  • delete tag, meta or field entries based on a condition
  • normalize units (metrics only)
  • change unit prefixes and consequently the metric value based on a condition (metrics only)

It accepts a json.RawMessage as configuration and parses it. Therefore it can be integrated into other configs:

type myConfig struct {
  Myfield string `json:"myfield"`
  MessageProcessor json.RawMessage `json:"process_messages"`
}

For initialization:

p, err := mp.NewMessageProcessor()
if err != nil {
  return fmt.Errorf("initialization of message processor failed: %v", err.Error())
}
err = p.FromConfigJSON(config.MessageProcessor)
if err != nil {
  return fmt.Errorf("failed parsing JSON for message processor: %v", err.Error())
}

Usage:

drop, err := p.ProcessMessage(msg)
if err == nil && !drop {
  // do something with m
}

Rules can also be added and removed at runtime using the various Add/Remove functions of p (in the above examples).

Plan is to integrate it in every component that sends or receives messages to filter them based on the configuration.

  • Only accept events through an receiver
  • Send messages with different units per sink
  • Rename only for PrometheusSink (as an example)

@TomTheBear TomTheBear merged commit 21646e1 into main Dec 11, 2024
5 checks passed
@TomTheBear TomTheBear deleted the message_processor branch December 11, 2024 18:06
TomTheBear added a commit that referenced this pull request Dec 11, 2024
* Add cpu_used (all-cpu_idle) to CpustatCollector

* Update cc-metric-collector.init

* Allow selection of timestamp precision in HttpSink

* Add comment about precision requirement for cc-metric-store

* Fix for API changes in [email protected]

* Update requirements to latest version

* Read sensors through redfish

* Update golang toolchain to 1.21

* Remove stray error check

* Update main config in configuration.md

* Update Release action to use golang 1.22 stable release, no golang RPMs anymore

* Update runonce action to use golang 1.22 stable release, no golang RPMs anymore

* New message processor to check whether a message should be dropped or manipulate it in flight

* Create a copy of message before manipulation

---------

Co-authored-by: Holger Obermaier <[email protected]>
Co-authored-by: Holger Obermaier <[email protected]>
TomTheBear added a commit that referenced this pull request Dec 19, 2024
* Add cpu_used (all-cpu_idle) to CpustatCollector

* Update cc-metric-collector.init

* Allow selection of timestamp precision in HttpSink

* Add comment about precision requirement for cc-metric-store

* Fix for API changes in [email protected]

* Update requirements to latest version

* Read sensors through redfish

* Update golang toolchain to 1.21

* Remove stray error check

* Update main config in configuration.md

* Update Release action to use golang 1.22 stable release, no golang RPMs anymore

* Update runonce action to use golang 1.22 stable release, no golang RPMs anymore

* Update README.md

Use right JSON type in configuration

* Update sink's README

* Test whether ipmitool or ipmi-sensors can be executed without errors

* Little fixes to the prometheus sink (#115)

* Add uint64 to float64 cast option

* Add prometheus sink to the list of available sinks

* Add aggregated counters by gpu for nvlink errors

---------

Co-authored-by: Michael Schwarz <[email protected]>

* Ccmessage migration (#119)

* Add cpu_used (all-cpu_idle) to CpustatCollector

* Update cc-metric-collector.init

* Allow selection of timestamp precision in HttpSink

* Add comment about precision requirement for cc-metric-store

* Fix for API changes in [email protected]

* Update requirements to latest version

* Read sensors through redfish

* Update golang toolchain to 1.21

* Remove stray error check

* Update main config in configuration.md

* Update Release action to use golang 1.22 stable release, no golang RPMs anymore

* Update runonce action to use golang 1.22 stable release, no golang RPMs anymore

* Switch to CCMessage for all files.

---------

Co-authored-by: Holger Obermaier <[email protected]>
Co-authored-by: Holger Obermaier <[email protected]>

* Switch to ccmessage also for latest additions in nvidiaMetric

* New Message processor (#118)

* Add cpu_used (all-cpu_idle) to CpustatCollector

* Update cc-metric-collector.init

* Allow selection of timestamp precision in HttpSink

* Add comment about precision requirement for cc-metric-store

* Fix for API changes in [email protected]

* Update requirements to latest version

* Read sensors through redfish

* Update golang toolchain to 1.21

* Remove stray error check

* Update main config in configuration.md

* Update Release action to use golang 1.22 stable release, no golang RPMs anymore

* Update runonce action to use golang 1.22 stable release, no golang RPMs anymore

* New message processor to check whether a message should be dropped or manipulate it in flight

* Create a copy of message before manipulation

---------

Co-authored-by: Holger Obermaier <[email protected]>
Co-authored-by: Holger Obermaier <[email protected]>

* Update collector's Makefile and go.mod/sum files

* Use message processor in router, all sinks and all receivers

* Add support for credential file (NKEY) to NATS sink and receiver

* Fix JSON keys in message processor configuration

* Update docs for message processor, router and the default router config file

* Add link to expr syntax and fix regex matching docs

* Update sample collectors

* Minor style change in collector manager

* Some helpers for ccTopology

* LIKWID collector: write log owner change only once

* Fix for metrics without units and reduce debugging messages for messageProcessor

* Use shorted hostname for hostname added by router

* Define default port for NATS

* CPUstat collector: only add unit for applicable metrics

* Add precision option to all sinks using Influx's encoder

* Add message processor to all sink documentation

* Add units to documentation of cpustat collector

---------

Co-authored-by: Holger Obermaier <[email protected]>
Co-authored-by: Holger Obermaier <[email protected]>
Co-authored-by: oscarminus <[email protected]>
Co-authored-by: Michael Schwarz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants