Skip to content

Commit

Permalink
[receiver/hostmetrics] Add filesystem utilization (#8027)
Browse files Browse the repository at this point in the history
* add hostmetricsreceiver filesystem utilization

* update changelog

* fix: update metadata.yaml

* remove state for utilization, disabled by default

* fix failing test due to disabled metric

* change system.filesystem.utilization description

* re-generate system.filesystem.utilization

* make system.filesystem.utilization fraction of 1

* go fmt

* update changelog

Co-authored-by: Dmitrii Anoshin <[email protected]>
  • Loading branch information
brushknight and dmitryax committed Mar 7, 2022
1 parent 59bc5f0 commit b48359b
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### 💡 Enhancements 💡

- `hostreceiver/filesystemscraper`: Add filesystem utilization (#8027)
- `googlecloudexporter`: [Alpha] Translate metrics directly from OTLP to gcm using the `exporter.googlecloud.OTLPDirect` feature-gate (#7177)
- `simpleprometheusreceiver`: Add support for static labels (#7908)
- `podmanreceiver`: Add container.runtime attribute to container metrics (#8262)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ These are the metrics available for this scraper.
| ---- | ----------- | ---- | ---- | ---------- |
| **system.filesystem.inodes.usage** | FileSystem inodes used. | {inodes} | Sum(Int) | <ul> <li>device</li> <li>mode</li> <li>mountpoint</li> <li>type</li> <li>state</li> </ul> |
| **system.filesystem.usage** | Filesystem bytes used. | By | Sum(Int) | <ul> <li>device</li> <li>mode</li> <li>mountpoint</li> <li>type</li> <li>state</li> </ul> |
| system.filesystem.utilization | Fraction of filesystem bytes used. | 1 | Gauge(Double) | <ul> <li>device</li> <li>mode</li> <li>mountpoint</li> <li>type</li> </ul> |

**Highlighted metrics** are emitted by default. Other metrics are optional and not emitted by default.
Any metric can be enabled or disabled with the following scraper configuration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ const fileSystemStatesLen = 2
func (s *scraper) recordFileSystemUsageMetric(now pdata.Timestamp, deviceUsages []*deviceUsage) {
for _, deviceUsage := range deviceUsages {
s.mb.RecordSystemFilesystemUsageDataPoint(
now, int64(deviceUsage.usage.Used), deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts), deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype, metadata.AttributeState.Used)
now, int64(deviceUsage.usage.Used),
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype,
metadata.AttributeState.Used)
s.mb.RecordSystemFilesystemUsageDataPoint(
now, int64(deviceUsage.usage.Free), deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts), deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype, metadata.AttributeState.Free)
now, int64(deviceUsage.usage.Free),
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype,
metadata.AttributeState.Free)
s.mb.RecordSystemFilesystemUtilizationDataPoint(
now, deviceUsage.usage.UsedPercent/100.0,
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ func (s *scraper) recordFileSystemUsageMetric(now pdata.Timestamp, deviceUsages
s.mb.RecordSystemFilesystemUsageDataPoint(
now, int64(deviceUsage.usage.Used),
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts), deviceUsage.partition.Mountpoint,
deviceUsage.partition.Fstype, metadata.AttributeState.Used)
deviceUsage.partition.Fstype,
metadata.AttributeState.Used)
s.mb.RecordSystemFilesystemUsageDataPoint(
now, int64(deviceUsage.usage.Free),
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype, metadata.AttributeState.Free)
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype,
metadata.AttributeState.Free)
s.mb.RecordSystemFilesystemUsageDataPoint(
now, int64(deviceUsage.usage.Total-deviceUsage.usage.Used-deviceUsage.usage.Free),
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype, metadata.AttributeState.Reserved)
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype,
metadata.AttributeState.Reserved)
s.mb.RecordSystemFilesystemUtilizationDataPoint(
now, deviceUsage.usage.UsedPercent/100.0,
deviceUsage.partition.Device, getMountMode(deviceUsage.partition.Opts),
deviceUsage.partition.Mountpoint, deviceUsage.partition.Fstype)
}
}

Expand Down

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 @@ -37,3 +37,11 @@ metrics:
aggregation: cumulative
monotonic: false
attributes: [device, mode, mountpoint, type, state]

system.filesystem.utilization:
enabled: false
description: Fraction of filesystem bytes used.
unit: 1
gauge:
value_type: double
attributes: [device, mode, mountpoint, type]

0 comments on commit b48359b

Please sign in to comment.