Skip to content

Commit

Permalink
feature: add ovirtstat_version tag to internal_ovirtstat metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tbelda-ems committed Jun 26, 2023
1 parent e0a79ba commit fc00f9b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
- status_code (int) 0-up, 1-paused, 2..9-misc, 10-unknown, 11-unassigned, 12-notresponding, 13-down
- internal_ovirtstat
- tags:
- alias
- ovirt-engine
- ovirtstat_version
- fields:
- sessions_created (int)
- gather_time_ns (int)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ovirtstat_storagedomain,id=072cba31-08f3-4a40-9f24-a5ca22ed1d74,name=ovirt-image
ovirtstat_storagedomain,id=ec413fb2-c6ce-4bea-a790-2533b728ac93,name=mysd01,ovirt-engine=myovirt,storage_type=fcp,type=data available=3233036632064i,connections=7,committed=16603269824512i,external_status="ok",external_status_code=0,logical_units=1i,master=true,status="",status_code=3i,used=7761005903872i 1677832224000000000
ovirtstat_glustervolume,clustername=mycluster,dcname=mydc,id=a1d52f5d-6vc3-42a8-a52f-21fe7dde25c2,name=mygv1,ovirt-engine=myovirt,type=stripe briks=1i,disperse_count=0i,redundancy_count=0i,replica_count=0i,status="up",status_code=0i,stripe_count=1i 1677832224000000000
virtstat_vm,clustername=mycluster,dcname=mydc,hostname=myhyp01,id=125555e7-fa2c-4d95-a5c4-51f1b9a7f563,name=myvm01,ovirt-engine=myovirt,type=server cpu_cores=1i,cpu_threads=2i,run_once=false,status="up",cpu_sockets=2i,memory_size=40802189312i,stateless=false,status_code=0i 1677832224000000000
internal_ovirtstat,ovirt-engine=myovirt sessions_created=1i,gather_time_ns=803780400i 1677832224000000000
internal_ovirtstat,ovirt-engine=myovirt,ovirtstat_version=0.1.0 sessions_created=1i,gather_time_ns=803780400i 1677832224000000000
```

# Metrics
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func main() {
os.Exit(0)
}
oV := ovirtstat.New()
oV.SetVersion(Version)

// load config an wait for stdin signal from telegraf to gather data
if *configFile != "" {
Expand Down
11 changes: 9 additions & 2 deletions plugins/inputs/ovirtstat/ovirtstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Config struct {
collectors map[string]bool
filterCollectors filter.Filter

version string
pollInterval time.Duration
ovc *ovirtcollector.OVirtCollector

Expand Down Expand Up @@ -160,8 +161,9 @@ func (c *Config) Start() error {

// selfmonitoring
tags = map[string]string{
"alias": c.InternalAlias,
"ovirt-engine": u.Hostname(),
"alias": c.InternalAlias,
"ovirt-engine": u.Hostname(),
"ovirtstat_version": c.version,
}
t = metric.TimeWithPrecision(time.Now(), intervalPrecision(c.pollInterval))
c.selfMon = metric.New("internal_ovirtstat", tags, nil, t)
Expand All @@ -184,6 +186,11 @@ func (c *Config) SetPollInterval(pollInterval time.Duration) error {
return nil
}

// SetVersion lets shim know this version
func (c *Config) SetVersion(version string) {
c.version = version
}

// SampleConfig returns a set of default configuration to be used as a boilerplate when setting up
// Telegraf.
func (c *Config) SampleConfig() string {
Expand Down

0 comments on commit fc00f9b

Please sign in to comment.