cc-metric-collector/sinks
Thomas Gruber 200af84c54
Modularize the whole thing (#16)
* Use channels, add a metric router, split up configuration and use extended version of Influx line protocol internally

* Use central timer for collectors and router. Add expressions to router

* Add expression to router config

* Update entry points

* Start with README

* Update README for CCMetric

* Formatting

* Update README.md

* Add README for MultiChanTicker

* Add README for MultiChanTicker

* Update README.md

* Add README to metric router

* Update main README

* Remove SinkEntity type

* Update README for sinks

* Update go files

* Update README for receivers

* Update collectors README

* Update collectors README

* Use seperate page per collector

* Fix for tempstat page

* Add docs for customcmd collector

* Add docs for ipmistat collector

* Add docs for topprocs collector

* Update customCmdMetric.md

* Use seconds when calculating LIKWID metrics

* Add IB metrics ib_recv_pkts and ib_xmit_pkts

* Drop domain part of host name

* Updated to latest stable version of likwid

* Define source code dependencies in Makefile

* Add GPFS / IBM Spectrum Scale collector

* Add vet and staticcheck make targets

* Add vet and staticcheck make targets

* Avoid go vet warning:
struct field tag `json:"..., omitempty"` not compatible with reflect.StructTag.Get: suspicious space in struct tag value
struct field tag `json:"...", omitempty` not compatible with reflect.StructTag.Get: key:"value" pairs not separated by spaces

* Add sample collector to README.md

* Add CPU frequency collector

* Avoid staticcheck warning: redundant return statement

* Avoid staticcheck warning: unnecessary assignment to the blank identifier

* Simplified code

* Add CPUFreqCollectorCpuinfo
a metric collector to measure the current frequency of the CPUs
as obtained from /proc/cpuinfo
Only measure on the first hyperthread

* Add collector for NFS clients

* Move publication of metrics into Flush() for NatsSink

* Update GitHub actions

* Refactoring

* Avoid vet warning: Println arg list ends with redundant newline

* Avoid vet warning struct field commands has json tag but is not exported

* Avoid vet warning: return copies lock value.

* Corrected typo

* Refactoring

* Add go sources in internal/...

* Bad separator in Makefile

* Fix Infiniband collector

Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com>
2022-01-25 15:37:43 +01:00
..
httpSink.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
influxSink.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
metricSink.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
natsSink.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
README.md Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
sinkManager.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00
stdoutSink.go Modularize the whole thing (#16) 2022-01-25 15:37:43 +01:00

CCMetric sinks

This folder contains the SinkManager and sink implementations for the cc-metric-collector.

Configuration

The configuration file for the sinks is a list of configurations. The type field in each specifies which sink to initialize.

[
  {
    "type" : "stdout",
    "meta_as_tags" : false
  },
  {
    "type" : "http",
    "host" : "localhost",
    "port" : "4123",
    "database" : "ccmetric",
    "password" : "<jwt token>"
  }
]

This example initializes two sinks, the stdout sink printing all metrics to the STDOUT and the http sink with the given host, port, database and password.

If meta_as_tags is set, all meta information attached to CCMetric are printed out as tags.

Type stdout

{
  "type" : "stdout",
  "meta_as_tags" : <true|false>
}

The stdout sink dumps all metrics to the STDOUT.

Type http

{
  "type" : "http",
  "host" : "<hostname>",
  "port" : "<portnumber>",
  "database" : "<database name>",
  "password" : "<jwt token>",
  "meta_as_tags" : <true|false>
}

The sink uses POST requests to send metrics to http://<host>:<port>/<database> using the JWT token as a JWT in the 'Authorization' header.

Type nats

{
  "type" : "nats",
  "host" : "<hostname>",
  "port" : "<portnumber>",
  "user" : "<username>",
  "password" : "<password>",
  "database" : "<database name>"
  "meta_as_tags" : <true|false>
}

This sink publishes the CCMetric in a NATS environment using host, port, user and password for connecting. The metrics are published using the topic database.

Type influxdb

{
  "type" : "influxdb",
  "host" : "<hostname>",
  "port" : "<portnumber>",
  "user" : "<username>",
  "password" : "<password or API key>",
  "database" : "<database name>"
  "organization": "<InfluxDB v2 organization>",
  "ssl" : <true|false>,
  "meta_as_tags" : <true|false>
}

This sink submits the CCMetrics to an InfluxDB time-series database. It uses host, port and ssl for connecting. For authentification, it uses either user:password if user is set and only password as API key. The organization and database are used for writing to the correct database.

Contributing own sinks

A sink contains three functions and is derived from the type Sink:

  • Init(config SinkConfig) error
  • Write(point CCMetric) error
  • Flush() error
  • Close()

The data structures should be set up in Init() like opening a file or server connection. The Write() function writes/sends the data. For non-blocking sinks, the Flush() method tells the sink to drain its internal buffers. The Close() function should tear down anything created in Init().

Finally, the sink needs to be registered in the sinkManager.go. There is a list of sinks called AvailableSinks which is a map (sink_type_string -> pointer to sink interface). Add a new entry with a descriptive name and the new sink.