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

feat: Influxdb dashboards #466

Merged
merged 3 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Hardware requirements depend on how many clusters you monitor and the number of
Harvest is compatible with:
- Prometheus: `2.24` or higher
- InfluxDB: `v2`
- Grafana: `7.4.2` or higher
- Grafana: `7.4.2` or higher (for Prometheus-based dashboards) or `v8.1.1` or higher (for InfluxDB-based dashboards)
- Docker: `20.10.0` or higher

# Installation / Upgrade
Expand Down
1 change: 1 addition & 0 deletions cmd/exporters/influxdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

The InfluxDB Exporter will format metrics into the InfluxDB's [line protocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/#naming-restrictions) and write it into a bucket. The Exporter is compatible with InfluxDB v2.0. For explanation about `bucket`, `org` and `precision`, see [InfluxDB API documentation](https://docs.influxdata.com/influxdb/v2.0/api/#tag/Write).

If you are monitoring both cdot and 7mode clusters, it is strongly recommended to use two different buckets.

## Parameters
Overview of all parameters is provided below. Only one of `url` and `addr` should be provided (at least one is required).
Expand Down
27 changes: 19 additions & 8 deletions cmd/exporters/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ const (
expectedResponseCode = 204
)

// some field names that we need to avoid
// first two: to avoid collision with label names
// others: protected field names by influxdb
var protectedFieldNames = map[string]string{
"status": "status_code",
"new_status": "new_status_code",
"time": "harvest_time",
"_measurement": "harvest_measurement",
"_field": "harvest_field",
}

type InfluxDB struct {
*exporter.AbstractExporter
client *http.Client
Expand Down Expand Up @@ -162,20 +173,16 @@ func (e *InfluxDB) Export(data *matrix.Matrix) error {
e.Logger.Debug().Msgf("(%s.%s) --> exported %d data points", data.Object, data.UUID, len(metrics))

// update metadata
if err = e.Metadata.LazyAddValueInt64("time", "export", time.Since(s).Microseconds()); err != nil {
e.Logger.Error().Stack().Err(err).Msg("metadata export time")
if err = e.Metadata.LazySetValueInt64("time", "export", time.Since(s).Microseconds()); err != nil {
e.Logger.Error().Err(err).Msg("metadata export time")
}

/* skipped for now, since InfluxDB complains about "time" field name

// export metadata
if metrics, err = e.Render(e.Metadata); err != nil {
logger.Error(e.Prefix, "render metadata: %v", err)
e.Logger.Error().Err(err).Msg("render metadata")
} else if err = e.Emit(metrics); err != nil {
logger.Error(e.Prefix, "emit metadata: %v", err)
e.Logger.Error().Err(err).Msg("emit metadata")
}

*/
return nil
}

Expand Down Expand Up @@ -307,6 +314,10 @@ func (e *InfluxDB) Render(data *matrix.Matrix) ([][]byte, error) {
}
}

if rename, has := protectedFieldNames[field_name]; has {
field_name = rename
}

m.AddField(field_name, value)
countTmp++
}
Expand Down
1 change: 0 additions & 1 deletion conf/zapiperf/cdot/9.8.0/system_node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ counters:
- instance_name
- avg_processor_busy
- cpu_elapsed_time
- uptime
- memory
- total_data
- total_latency
Expand Down
Loading