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

Cherry-pick #17966 to 7.x: Metricbeat add IIS module dashboards #18167

Merged
merged 1 commit into from
May 4, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Reference kubernetes manifests mount data directory from the host when running metricbeat as daemonset, so data persist between executions in the same node. {pull}17429[17429]
- Add more detailed error messages, system tests and small refactoring to the service metricset in windows. {pull}17725[17725]
- Stack Monitoring modules now auto-configure required metricsets when `xpack.enabled: true` is set. {issue}16471[[16471] {pull}17609[17609]
- Add Metricbeat IIS module dashboards. {pull}17966[17966]
- Add dashboard for the azure database account metricset. {pull}17901[17901]
- Allow partial region and zone name in googlecloud module config. {pull}17913[17913]
- Add aggregation aligner as a config parameter for googlecloud stackdriver metricset. {issue}17141[[17141] {pull}17719[17719]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ This file is generated! See scripts/mage/docs_collector.go
|<<metricbeat-metricset-http-server,server>>
|<<metricbeat-module-ibmmq,IBM MQ>> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.1+| .1+| |<<metricbeat-metricset-ibmmq-qmgr,qmgr>> beta[]
|<<metricbeat-module-iis,iis>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
|<<metricbeat-module-iis,iis>> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.3+| .3+| |<<metricbeat-metricset-iis-application_pool,application_pool>> beta[]
|<<metricbeat-metricset-iis-webserver,webserver>> beta[]
|<<metricbeat-metricset-iis-website,website>> beta[]
Expand Down
132 changes: 67 additions & 65 deletions metricbeat/module/windows/perfmon/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,54 +38,52 @@ var processRegexp = regexp.MustCompile(`(.+?)#[1-9]+`)
func (re *Reader) groupToEvents(counters map[string][]pdh.CounterValue) []mb.Event {
eventMap := make(map[string]*mb.Event)
for counterPath, values := range counters {
hasCounter, counter := re.getCounter(counterPath)
for ind, val := range values {
// Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if val.Err != nil && !re.executed {
re.log.Debugw("Ignoring the first measurement because the data isn't ready",
"error", val.Err, logp.Namespace("perfmon"), "query", counterPath)
continue
}

var eventKey string
if re.config.GroupMeasurements && val.Err == nil {
// Send measurements with the same instance label as part of the same event
eventKey = val.Instance
} else {
// Send every measurement as an individual event
// If a counter contains an error, it will always be sent as an individual event
eventKey = counterPath + strconv.Itoa(ind)
}

// Create a new event if the key doesn't exist in the map
if _, ok := eventMap[eventKey]; !ok {
eventMap[eventKey] = &mb.Event{
MetricSetFields: common.MapStr{},
Error: errors.Wrapf(val.Err, "failed on query=%v", counterPath),
if hasCounter, counter := re.getCounter(counterPath); hasCounter {
for ind, val := range values {
// Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if val.Err != nil && !re.executed {
re.log.Debugw("Ignoring the first measurement because the data isn't ready",
"error", val.Err, logp.Namespace("perfmon"), "query", counterPath)
continue
}
if val.Instance != "" && hasCounter {
//will ignore instance counter
if ok, match := matchesParentProcess(val.Instance); ok {
eventMap[eventKey].MetricSetFields.Put(counter.InstanceField, match)
} else {
eventMap[eventKey].MetricSetFields.Put(counter.InstanceField, val.Instance)
var eventKey string
if re.config.GroupMeasurements && val.Err == nil {
// Send measurements with the same instance label as part of the same event
eventKey = val.Instance
} else {
// Send every measurement as an individual event
// If a counter contains an error, it will always be sent as an individual event
eventKey = counterPath + strconv.Itoa(ind)
}
// Create a new event if the key doesn't exist in the map
if _, ok := eventMap[eventKey]; !ok {
eventMap[eventKey] = &mb.Event{
MetricSetFields: common.MapStr{},
Error: errors.Wrapf(val.Err, "failed on query=%v", counterPath),
}
if val.Instance != "" {
//will ignore instance counter
if ok, match := matchesParentProcess(val.Instance); ok {
eventMap[eventKey].MetricSetFields.Put(counter.InstanceField, match)
} else {
eventMap[eventKey].MetricSetFields.Put(counter.InstanceField, val.Instance)
}
}
}
}
event := eventMap[eventKey]
if val.Measurement != nil {
event.MetricSetFields.Put(counter.QueryField, val.Measurement)
} else {
event.MetricSetFields.Put(counter.QueryField, 0)
}
if counter.ObjectField != "" {
event.MetricSetFields.Put(counter.ObjectField, counter.ObjectName)
if val.Measurement != nil {
eventMap[eventKey].MetricSetFields.Put(counter.QueryField, val.Measurement)
} else {
eventMap[eventKey].MetricSetFields.Put(counter.QueryField, 0)
}
if counter.ObjectField != "" {
eventMap[eventKey].MetricSetFields.Put(counter.ObjectField, counter.ObjectName)
}
}
}
}
// Write the values into the map.
events := make([]mb.Event, 0, len(eventMap))
var events []mb.Event
for _, val := range eventMap {
events = append(events, *val)
}
Expand All @@ -98,30 +96,34 @@ func (re *Reader) groupToSingleEvent(counters map[string][]pdh.CounterValue) mb.
}
measurements := make(map[string]float64, 0)
for counterPath, values := range counters {
_, readerCounter := re.getCounter(counterPath)
for _, val := range values {
// Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if val.Err != nil && !re.executed {
re.log.Debugw("Ignoring the first measurement because the data isn't ready",
"error", val.Err, logp.Namespace("perfmon"), "query", counterPath)
continue
}
var counterVal float64
switch val.Measurement.(type) {
case int64:
counterVal = float64(val.Measurement.(int64))
case int:
counterVal = float64(val.Measurement.(int))
default:
counterVal = val.Measurement.(float64)
}
if _, ok := measurements[readerCounter.QueryField]; !ok {
measurements[readerCounter.QueryField] = counterVal
measurements[readerCounter.QueryField+instanceCountLabel] = 1
} else {
measurements[readerCounter.QueryField+instanceCountLabel] = measurements[readerCounter.QueryField+instanceCountLabel] + 1
measurements[readerCounter.QueryField] = measurements[readerCounter.QueryField] + counterVal
if hasCounter, readerCounter := re.getCounter(counterPath); hasCounter {
for _, val := range values {
// Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if val.Err != nil && !re.executed {
re.log.Debugw("Ignoring the first measurement because the data isn't ready",
"error", val.Err, logp.Namespace("perfmon"), "query", counterPath)
continue
}
if val.Measurement == nil {
continue
}
var counterVal float64
switch val.Measurement.(type) {
case int64:
counterVal = float64(val.Measurement.(int64))
case int:
counterVal = float64(val.Measurement.(int))
default:
counterVal = val.Measurement.(float64)
}
if _, ok := measurements[readerCounter.QueryField]; !ok {
measurements[readerCounter.QueryField] = counterVal
measurements[readerCounter.QueryField+instanceCountLabel] = 1
} else {
measurements[readerCounter.QueryField+instanceCountLabel] = measurements[readerCounter.QueryField+instanceCountLabel] + 1
measurements[readerCounter.QueryField] = measurements[readerCounter.QueryField] + counterVal
}
}
}
}
Expand Down
Loading