Rename interrupts cpu_as_tags to cpu_as_tag; update readme

This commit is contained in:
Daniel Nelson 2018-11-30 15:00:38 -08:00
parent 9a637eda05
commit 7479352e4a
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
4 changed files with 80 additions and 42 deletions

View File

@ -3,48 +3,81 @@
The interrupts plugin gathers metrics about IRQs from `/proc/interrupts` and `/proc/softirqs`. The interrupts plugin gathers metrics about IRQs from `/proc/interrupts` and `/proc/softirqs`.
### Configuration ### Configuration
``` ```toml
[[inputs.interrupts]] [[inputs.interrupts]]
# To report cpus as tags instead of fields use cpu_as_tags ## When set to true, cpu metrics are tagged with the cpu. Otherwise cpu is
# cpu_as_tags = false ## stored as a field.
# ##
## The default is false for backwards compatibility, and will be changed to
## true in a future version. It is recommended to set to true on new
## deployments.
# cpu_as_tag = false
## To filter which IRQs to collect, make use of tagpass / tagdrop, i.e. ## To filter which IRQs to collect, make use of tagpass / tagdrop, i.e.
# [inputs.interrupts.tagdrop] # [inputs.interrupts.tagdrop]
# irq = [ "NET_RX", "TASKLET" ] # irq = [ "NET_RX", "TASKLET" ]
``` ```
### Measurements ### Metrics
There are two measurements reported by this plugin.
- `interrupts` gathers metrics from the `/proc/interrupts` file
- `soft_interrupts` gathers metrics from the `/proc/softirqs` file
### Fields There are two styles depending on the value of `cpu_as_tag`.
For cpu_as_tags=false (default):
- CPUx: the amount of interrupts for the IRQ handled by the CPU
- Total: sum of interrupts for the IRS for all CPUs
For cpu_as_tags=true ():
- Count: the amount of interrupts for the IRQ handled by CPU described in CPU tag
### Tags With `cpu_as_tag = false`:
- irq: the IRQ
- type: the type of interrupt - interrupts
- device: the name of the device that is located at that IRQ - tags:
- cpu: the CPU (when cpus_as_tags=true) - irq (IRQ name)
- type
- device (name of the device that is located at the IRQ)
- cpu
- fields:
- cpu (int, number of interrupts per cpu)
- total (int, total number of interrupts)
- soft_interrupts
- tags:
- irq (IRQ name)
- type
- device (name of the device that is located at the IRQ)
- cpu
- fields:
- cpu (int, number of interrupts per cpu)
- total (int, total number of interrupts)
With `cpu_as_tag = true`:
- interrupts
- tags:
- irq (IRQ name)
- type
- device (name of the device that is located at the IRQ)
- cpu
- fields:
- count (int, number of interrupts)
- soft_interrupts
- tags:
- irq (IRQ name)
- type
- device (name of the device that is located at the IRQ)
- cpu
- fields:
- count (int, number of interrupts)
### Example Output ### Example Output
```
./telegraf --config ~/interrupts_config.conf --test
For cpus_as_tags=false (default):
* Plugin: inputs.interrupts, Collection 1
> interrupts,irq=0,type=IO-APIC,device=2-edge\ timer,host=hostname,cpu=cpu0 count=23i 1489346531000000000
> interrupts,irq=1,host=hostname,type=IO-APIC,device=1-edge\ i8042,cpu=cpu0 count=9i 1489346531000000000
> interrupts,irq=30,type=PCI-MSI,device=65537-edge\ virtio1-input.0,host=hostname,cpu=cpu1 count=1i 1489346531000000000
> soft_interrupts,irq=NET_RX,host=hostname,cpu=cpu0 count=280879i 1489346531000000000
For cpus_as_tags=true:
> interrupts,cpu=cpu6,host=hostname,irq=PIW,type=Posted-interrupt\ wakeup\ event count=0i 1543539773000000000
> interrupts,cpu=cpu7,host=hostname,irq=PIW,type=Posted-interrupt\ wakeup\ event count=0i 1543539773000000000
> soft_interrupts,cpu=cpu0,host=hostname,irq=HI count=246441i 1543539773000000000
> soft_interrupts,cpu=cpu1,host=hostname,irq=HI count=159154i 1543539773000000000
With `cpu_as_tag = false`:
```
interrupts,irq=0,type=IO-APIC,device=2-edge\ timer,cpu=cpu0 count=23i 1489346531000000000
interrupts,irq=1,type=IO-APIC,device=1-edge\ i8042,cpu=cpu0 count=9i 1489346531000000000
interrupts,irq=30,type=PCI-MSI,device=65537-edge\ virtio1-input.0,cpu=cpu1 count=1i 1489346531000000000
soft_interrupts,irq=NET_RX,cpu=cpu0 count=280879i 1489346531000000000
```
With `cpu_as_tag = true`:
```
interrupts,cpu=cpu6,irq=PIW,type=Posted-interrupt\ wakeup\ event count=0i 1543539773000000000
interrupts,cpu=cpu7,irq=PIW,type=Posted-interrupt\ wakeup\ event count=0i 1543539773000000000
soft_interrupts,cpu=cpu0,irq=HI count=246441i 1543539773000000000
soft_interrupts,cpu=cpu1,irq=HI count=159154i 1543539773000000000
``` ```

View File

@ -13,7 +13,7 @@ import (
) )
type Interrupts struct { type Interrupts struct {
CpuAsTags bool CpuAsTag bool `toml:"cpu_as_tag"`
} }
type IRQ struct { type IRQ struct {
@ -29,9 +29,14 @@ func NewIRQ(id string) *IRQ {
} }
const sampleConfig = ` const sampleConfig = `
## To report cpus as tags instead of fields use cpu_as_tags ## When set to true, cpu metrics are tagged with the cpu. Otherwise cpu is
# cpu_as_tags = false ## stored as a field.
# ##
## The default is false for backwards compatibility, and will be changed to
## true in a future version. It is recommended to set to true on new
## deployments.
# cpu_as_tag = false
## To filter which IRQs to collect, make use of tagpass / tagdrop, i.e. ## To filter which IRQs to collect, make use of tagpass / tagdrop, i.e.
# [inputs.interrupts.tagdrop] # [inputs.interrupts.tagdrop]
# irq = [ "NET_RX", "TASKLET" ] # irq = [ "NET_RX", "TASKLET" ]
@ -116,7 +121,7 @@ func (s *Interrupts) Gather(acc telegraf.Accumulator) error {
acc.AddError(fmt.Errorf("Parsing %s: %s", file, err)) acc.AddError(fmt.Errorf("Parsing %s: %s", file, err))
continue continue
} }
reportMetrics(measurement, irqs, acc, s.CpuAsTags) reportMetrics(measurement, irqs, acc, s.CpuAsTag)
} }
return nil return nil
} }

View File

@ -23,7 +23,7 @@ a validating, recursive, and caching DNS resolver.
## When set to true, thread metrics are tagged with the thread id. ## When set to true, thread metrics are tagged with the thread id.
## ##
## The default is false for backwards compatibility, and will be change to ## The default is false for backwards compatibility, and will be changed to
## true in a future version. It is recommended to set to true on new ## true in a future version. It is recommended to set to true on new
## deployments. ## deployments.
thread_as_tag = false thread_as_tag = false

View File

@ -50,7 +50,7 @@ var sampleConfig = `
## When set to true, thread metrics are tagged with the thread id. ## When set to true, thread metrics are tagged with the thread id.
## ##
## The default is false for backwards compatibility, and will be change to ## The default is false for backwards compatibility, and will be changed to
## true in a future version. It is recommended to set to true on new ## true in a future version. It is recommended to set to true on new
## deployments. ## deployments.
thread_as_tag = false thread_as_tag = false