Skip to content

Commit

Permalink
Update dataset name and add a metric in process
Browse files Browse the repository at this point in the history
  • Loading branch information
ishleenk17 committed Feb 5, 2024
1 parent 6d9a005 commit fe8dcc2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ require (
github.com/influxdata/influxdb-observability/otel2influx v0.5.8 // indirect
github.com/influxdata/line-protocol/v2 v2.2.1 // indirect
github.com/ionos-cloud/sdk-go/v6 v6.1.9 // indirect
github.com/ishleenk17/opentelemetry-collector-contrib/processor/elasticprocessor v0.0.0-20240205053831-6d9a005cfe4b // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var scraperToElasticDataset = map[string]string{
"memory": "system.memory",
"network": "system.network",
"paging": "system.memory",
"processes": "system.process",
"processes": "system.process.summary",
"process": "system.process",
}

Expand Down
12 changes: 11 additions & 1 deletion processor/elasticprocessor/internal/hostmetrics/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func addProcessMetrics(metrics pmetric.MetricSlice, dataset string) error {
var timestamp pcommon.Timestamp
var threads, memUsage, memVirtual int64
var threads, memUsage, memVirtual, fdOpen int64
var memUtil float64

for i := 0; i < metrics.Len(); i++ {
Expand All @@ -28,6 +28,10 @@ func addProcessMetrics(metrics pmetric.MetricSlice, dataset string) error {
dp := metric.Sum().DataPoints().At(0)
timestamp = dp.Timestamp()
memVirtual = dp.IntValue()
} else if metric.Name() == "process.open_file_descriptors" {
dp := metric.Sum().DataPoints().At(0)
timestamp = dp.Timestamp()
fdOpen = dp.IntValue()
}
}

Expand Down Expand Up @@ -58,6 +62,12 @@ func addProcessMetrics(metrics pmetric.MetricSlice, dataset string) error {
timestamp: timestamp,
intValue: &memVirtual,
},
metric{
dataType: Sum,
name: "system.process.fd.open",
timestamp: timestamp,
intValue: &fdOpen,
},
)

return nil
Expand Down

0 comments on commit fe8dcc2

Please sign in to comment.