-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add improved config/event output options to windows/perfmon metricset #17596
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d526603
config
narph 22f51cf
work on perfmon
narph ad90e00
progress
narph a782840
work on perf
narph af5219c
Create tests
narph d54f74a
work on documentation
narph c360b9b
fix test
narph aec0615
changelog
narph 3d5101e
work on webserver
narph 1f1d2af
Merge branch 'master' into perfmon-ga
narph 644217a
fix test
narph 6416739
add test
narph ddc124d
validate
narph 4dbd811
dynamic mapping
narph 561be46
init format
narph ee0418c
work on test
narph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,8 +5,13 @@ This file is generated! See scripts/mage/docs_collector.go | |||||||||||||||||||||||||||||||||
[[metricbeat-module-windows]] | ||||||||||||||||||||||||||||||||||
== Windows module | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
This is the Windows module. It collects metrics from Windows systems, | ||||||||||||||||||||||||||||||||||
by default metricset `service` is enabled. | ||||||||||||||||||||||||||||||||||
This is the `windows` module which collects metrics from Windows systems. | ||||||||||||||||||||||||||||||||||
The module contains the `service` metricset, which is set up by default when the `windows` module is enabled. | ||||||||||||||||||||||||||||||||||
The `service` metricset will retrieve status information of the services on the Windows machines. The second `windows` | ||||||||||||||||||||||||||||||||||
metricset is `perfmon` which collects Windows performance counter values. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
[float] | ||||||||||||||||||||||||||||||||||
|
@@ -24,11 +29,14 @@ metricbeat.modules: | |||||||||||||||||||||||||||||||||
period: 10s | ||||||||||||||||||||||||||||||||||
perfmon.ignore_non_existent_counters: false | ||||||||||||||||||||||||||||||||||
perfmon.group_measurements_by_instance: false | ||||||||||||||||||||||||||||||||||
perfmon.counters: | ||||||||||||||||||||||||||||||||||
# - instance_label: processor.name | ||||||||||||||||||||||||||||||||||
# instance_name: total | ||||||||||||||||||||||||||||||||||
# measurement_label: processor.time.total.pct | ||||||||||||||||||||||||||||||||||
# query: '\Processor Information(_Total)\% Processor Time' | ||||||||||||||||||||||||||||||||||
perfmon.queries: | ||||||||||||||||||||||||||||||||||
# - object: 'Process' | ||||||||||||||||||||||||||||||||||
# instance: ["*"] | ||||||||||||||||||||||||||||||||||
# counters: | ||||||||||||||||||||||||||||||||||
# - name: 'Disk Writes/sec' | ||||||||||||||||||||||||||||||||||
# field: physical_disk.write.per_sec | ||||||||||||||||||||||||||||||||||
# format: "float" | ||||||||||||||||||||||||||||||||||
# - name: "% Disk Write Time" | ||||||||||||||||||||||||||||||||||
Comment on lines
+32
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit. Align the comment marks with the previous block:
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
- module: windows | ||||||||||||||||||||||||||||||||||
metricsets: ["service"] | ||||||||||||||||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
- module: windows | ||
#metricsets: | ||
# - service | ||
metricsets: | ||
- service | ||
period: 1m | ||
|
||
#- module: windows | ||
# metricsets: | ||
# - perfmon | ||
# - perfmon | ||
# period: 10s | ||
# perfmon.counters: | ||
# - instance_label: processor.name | ||
# instance_name: total | ||
# measurement_label: processor.time.total.pct | ||
# query: '\Processor Information(_Total)\% Processor Time' | ||
# | ||
# - instance_label: physical_disk.name | ||
# measurement_label: physical_disk.write.per_sec | ||
# query: '\PhysicalDisk(*)\Disk Writes/sec' | ||
# | ||
# - instance_label: physical_disk.name | ||
# measurement_label: physical_disk.write.time.pct | ||
# query: '\PhysicalDisk(*)\% Disk Write Time' | ||
# perfmon.queries: | ||
# - object: 'Process' | ||
# instance: ["*"] | ||
# counters: | ||
# - name: 'Disk Writes/sec' | ||
# field: physical_disk.write.per_sec | ||
# format: "float" | ||
# - name: "% Disk Write Time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
This is the Windows module. It collects metrics from Windows systems, | ||
by default metricset `service` is enabled. | ||
This is the `windows` module which collects metrics from Windows systems. | ||
The module contains the `service` metricset, which is set up by default when the `windows` module is enabled. | ||
The `service` metricset will retrieve status information of the services on the Windows machines. The second `windows` | ||
metricset is `perfmon` which collects Windows performance counter values. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
{ | ||
"@timestamp": "2017-10-12T08:05:34.853Z", | ||
"beat": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
"event": { | ||
"dataset": "windows.perfmon", | ||
"duration": 115000, | ||
"module": "windows" | ||
}, | ||
"metricset": { | ||
"module": "windows", | ||
"name": "perfmon", | ||
"rtt": 115 | ||
"period": 10000 | ||
}, | ||
"service": { | ||
"type": "windows" | ||
}, | ||
"windows": { | ||
"perfmon": { | ||
"processor": { | ||
"name": "_Total", | ||
"time": { | ||
"total": { | ||
"pct": 1.4663385364361736 | ||
"instance": "_Total", | ||
"metrics": { | ||
"processor": { | ||
"time": { | ||
"total": { | ||
"pct": 6.310940413107646 | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"object": "Processor Information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// +build windows | ||
|
||
package perfmon | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/elastic/beats/v7/libbeat/common/cfgwarn" | ||
) | ||
|
||
const replaceUpperCaseRegex = `(?:[^A-Z_\W])([A-Z])[^A-Z]` | ||
|
||
var allowedFormats = []string{"float", "large", "long"} | ||
|
||
// Config for the windows perfmon metricset. | ||
type Config struct { | ||
IgnoreNECounters bool `config:"perfmon.ignore_non_existent_counters"` | ||
GroupMeasurements bool `config:"perfmon.group_measurements_by_instance"` | ||
Counters []Counter `config:"perfmon.counters"` | ||
Queries []Query `config:"perfmon.queries"` | ||
GroupAllCountersTo string `config:"perfmon.group_all_counter"` | ||
} | ||
|
||
// Counter for the perfmon counters (old implementation deprecated). | ||
type Counter struct { | ||
InstanceLabel string `config:"instance_label"` | ||
InstanceName string `config:"instance_name"` | ||
MeasurementLabel string `config:"measurement_label" validate:"required"` | ||
Query string `config:"query" validate:"required"` | ||
Format string `config:"format"` | ||
} | ||
|
||
// QueryConfig for perfmon queries. This will be used as the new configuration format | ||
type Query struct { | ||
Name string `config:"object" validate:"required"` | ||
Field string `config:"field"` | ||
Instance []string `config:"instance"` | ||
Counters []QueryCounter `config:"counters" validate:"required"` | ||
Namespace string `config:"namespace"` | ||
} | ||
|
||
// QueryConfigCounter for perfmon queries. This will be used as the new configuration format | ||
type QueryCounter struct { | ||
Name string `config:"name" validate:"required"` | ||
Field string `config:"field"` | ||
Format string `config:"format"` | ||
} | ||
|
||
func (query *Query) InitDefaults() { | ||
query.Namespace = "metrics" | ||
} | ||
|
||
func (counter *QueryCounter) InitDefaults() { | ||
form := strings.ToLower(counter.Format) | ||
switch form { | ||
case "", "float": | ||
counter.Format = "float" | ||
case "long", "large": | ||
} | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func (counter *Counter) InitDefaults() { | ||
form := strings.ToLower(counter.Format) | ||
switch form { | ||
case "", "float": | ||
counter.Format = "float" | ||
case "long", "large": | ||
} | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func (conf *Config) Validate() error { | ||
if len(conf.Counters) == 0 && len(conf.Queries) == 0 { | ||
return errors.New("no perfmon counters or queries have been configured") | ||
} | ||
if len(conf.Counters) > 0 { | ||
cfgwarn.Deprecate("8.0", "perfmon.counters configuration option is deprecated and will be removed in the future major version, "+ | ||
"we advise using the perfmon.queries configuration option instead.") | ||
} | ||
if len(conf.Queries) > 0 { | ||
for _, query := range conf.Queries { | ||
if len(query.Counters) == 0 { | ||
return errors.Errorf("no perfmon counters have been configured for object %s", query.Name) | ||
} | ||
} | ||
} | ||
|
||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, value := range conf.Counters { | ||
if !isValidFormat(value.Format) { | ||
return errors.Errorf("initialization failed: format '%s' "+ | ||
"for counter '%s' is invalid (must be float, large or long)", | ||
value.Format, value.InstanceLabel) | ||
} | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} | ||
for _, value := range conf.Queries { | ||
for _, q := range value.Counters { | ||
if !isValidFormat(q.Format) { | ||
return errors.Errorf("initialization failed: format '%s' "+ | ||
"for counter '%s' is invalid (must be float, large or long)", | ||
q.Format, q.Field) | ||
} | ||
narph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} | ||
} | ||
return nil | ||
} | ||
|
||
func isValidFormat(format string) bool { | ||
for _, form := range allowedFormats { | ||
if form == format { | ||
jsoriano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true | ||
} | ||
} | ||
return false | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align commented out code as before?