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

Add metricbeat iis module #15059

Merged
merged 45 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9500d18
created iis module
narph Nov 19, 2018
bab0cd4
work in progress
narph Mar 27, 2019
66dfa82
Merge branch 'master' into iis-module
narph Dec 11, 2019
b1fba8f
iis changes
narph Dec 11, 2019
7a8ff78
add iis module
narph Dec 11, 2019
6bd81eb
light
narph Jan 15, 2020
3b7b520
Merge branch 'master' into iis-module
narph Jan 15, 2020
f5cb0a7
work on build
narph Jan 15, 2020
c320a53
work on build
narph Jan 15, 2020
9d5df82
build
narph Jan 15, 2020
222648e
fmt update
narph Jan 15, 2020
00e1a08
temp
narph Jan 16, 2020
258ded3
work on website
narph Jan 17, 2020
5f30e5a
temp
narph Jan 21, 2020
7ab4d2d
Merge branch 'master' into iis-module
narph Jan 21, 2020
92e5873
temp
narph Jan 22, 2020
f18b298
manifest changes
narph Jan 23, 2020
b770c57
temp
narph Jan 24, 2020
ea28cbe
temp
narph Jan 28, 2020
397296b
work on wp
narph Jan 31, 2020
411d9d9
adding application pool metricset
narph Feb 5, 2020
113eec5
wmi option
narph Feb 10, 2020
6aa632b
test
narph Feb 10, 2020
ca3f589
work on apppool
narph Feb 11, 2020
b739816
work on app pool
narph Feb 12, 2020
552c1b7
work on website metricset
narph Feb 12, 2020
d245579
Merge branch 'master' into iis-module
narph Feb 12, 2020
fadb63a
work on tests
narph Feb 13, 2020
706b393
Work on website
narph Feb 14, 2020
a1656be
work on website
narph Feb 14, 2020
4ab7fa8
Merge branch 'master' into iis-module
narph Feb 14, 2020
1d760b1
work on website
narph Feb 14, 2020
9645ff0
perfmon fix
narph Feb 14, 2020
ef247b8
work on websie
narph Feb 17, 2020
2e44357
update config
narph Feb 18, 2020
2e1cc66
Merge branch 'master' into iis-module
narph Feb 19, 2020
ecaa80f
feedback
narph Feb 19, 2020
fcfd4f3
work on feedback
narph Feb 21, 2020
118f55c
temp
narph Feb 24, 2020
d7b9eb9
Merge branch 'master' into iis-module
narph Feb 24, 2020
f8ab974
ecs
narph Feb 24, 2020
a40569e
Merge branch 'master' into iis-module
narph Feb 25, 2020
fbb7cd5
temp
narph Feb 25, 2020
5f1b016
add counters
narph Feb 26, 2020
ac81ebe
Merge branch 'master' into iis-module
narph Feb 27, 2020
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
68 changes: 68 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ grouped in the following categories:
* <<exported-fields-host-processor>>
* <<exported-fields-http>>
* <<exported-fields-ibmmq>>
* <<exported-fields-iis>>
* <<exported-fields-istio>>
* <<exported-fields-jolokia>>
* <<exported-fields-jolokia-autodiscover>>
Expand Down Expand Up @@ -16924,6 +16925,73 @@ IBM MQ module



[[exported-fields-iis]]
== iis fields

iis module



[float]
=== iis




[float]
=== application_pool

application_pool



*`iis.application_pool.name`*::
+
--
application pool name


type: keyword

--

*`iis.application_pool.worker_processor_id`*::
+
--
worker processor id


type: keyword

--

*`iis.webserver.*.*`*::
+
--
webserver


type: object

--

[float]
=== website

website



*`iis.website.name`*::
+
--
website name


type: keyword

--

[[exported-fields-istio]]
== istio fields

Expand Down
99 changes: 99 additions & 0 deletions metricbeat/docs/modules/iis.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-module-iis]]
== iis module

beta[]

This is the iis module.

IIS (Internet Information Services) is a secure, reliable, and scalable Web server that provides an easy to manage platform for developing and hosting Web applications and services.

The `iis` module will periodically retrieve IIS related metrics using performance counters such as:

- System/Process counters like the the overall server and CPU usage for the IIS Worker Process and memory (currently used and available memory for the IIS Worker Process).
- IIS performance counters like Web Service: Bytes Received/Sec, Web Service: Bytes Sent/Sec, etc, which are helpful to track to identify potential spikes in traffic.
- Web Service Cache counters in order to monitor user mode cache and output cache.

narph marked this conversation as resolved.
Show resolved Hide resolved

The `iis` module mericsets are `webserver`, `website` and `application_pool`.

[source,yaml]
----
- module: iis
metricsets:
- webserver
- website
- application_pool
enabled: true
period: 10s
# filter on application pool names
# application_pool.name: []
----

[float]
== Metricsets

[float]
=== `webserver`
A light metricset using the windows perfmon metricset as the base metricset.
This metricset allows users to retrieve aggregated metrics for the entire webserver,

[float]
=== `website`
A light metricset using the windows perfmon metricset as the base metricset.
This metricset will collect metrics of specific sites, users can configure which websites they want to monitor, else, all are considered.

[float]
=== `application_pool`
This metricset will collect metrics of specific application pools, users can configure which websites they want to monitor, else, all are considered.


[float]
=== Module-specific configuration notes

`application_pool.name`:: []string, users can specify the application pools they would like to monitor.



[float]
=== Example configuration

The iis module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: iis
metricsets:
- webserver
- website
- application_pool
enabled: true
period: 10s
# filter on application pool names
# application_pool.name: []
----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-iis-application_pool,application_pool>>

* <<metricbeat-metricset-iis-webserver,webserver>>

* <<metricbeat-metricset-iis-website,website>>

include::iis/application_pool.asciidoc[]

include::iis/webserver.asciidoc[]

include::iis/website.asciidoc[]

23 changes: 23 additions & 0 deletions metricbeat/docs/modules/iis/application_pool.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-iis-application_pool]]
=== iis application_pool metricset

beta[]

include::../../../module/iis/application_pool/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-iis,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/iis/application_pool/_meta/data.json[]
----
24 changes: 24 additions & 0 deletions metricbeat/docs/modules/iis/webserver.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-iis-webserver]]
=== iis webserver metricset

beta[]

include::../../../module/iis/webserver/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-iis,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/iis/webserver/_meta/data.json[]
----
24 changes: 24 additions & 0 deletions metricbeat/docs/modules/iis/website.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-iis-website]]
=== iis website metricset

beta[]

include::../../../module/iis/website/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-iis,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/iis/website/_meta/data.json[]
----
5 changes: 5 additions & 0 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ 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] |
.3+| .3+| |<<metricbeat-metricset-iis-application_pool,application_pool>> beta[]
|<<metricbeat-metricset-iis-webserver,webserver>> beta[]
|<<metricbeat-metricset-iis-website,website>> beta[]
|<<metricbeat-module-istio,istio>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.5+| .5+| |<<metricbeat-metricset-istio-citadel,citadel>> beta[]
|<<metricbeat-metricset-istio-galley,galley>> beta[]
Expand Down Expand Up @@ -273,6 +277,7 @@ include::modules/graphite.asciidoc[]
include::modules/haproxy.asciidoc[]
include::modules/http.asciidoc[]
include::modules/ibmmq.asciidoc[]
include::modules/iis.asciidoc[]
include::modules/istio.asciidoc[]
include::modules/jolokia.asciidoc[]
include::modules/kafka.asciidoc[]
Expand Down
18 changes: 15 additions & 3 deletions metricbeat/helper/windows/pdh/pdh_query_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (q *Query) AddCounter(counterPath string, instance string, format string, w
var instanceName string
// Extract the instance name from the counterPath.
if instance == "" || wildcard {
instanceName, err = matchInstanceName(counterPath)
instanceName, err = MatchInstanceName(counterPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -178,6 +178,18 @@ func (q *Query) GetFormattedCounterValues() (map[string][]CounterValue, error) {
return rtn, nil
}

// GetCountersAndInstances returns a list of counters and instances for a given object
func (q *Query) GetCountersAndInstances(objectName string) ([]string, []string, error) {
counters, instances, err := PdhEnumObjectItems(objectName)
if err != nil {
return nil, nil, errors.Wrapf(err, "Unable to retrieve counter and instance list for %s", objectName)
}
if len(counters) == 0 && len(instances) == 0 {
return nil, nil, errors.Errorf("Unable to retrieve counter and instance list for %s", objectName)
}
return UTF16ToStringArray(counters), UTF16ToStringArray(instances), nil
}

// ExpandWildCardPath examines local computer and returns those counter paths that match the given counter path which contains wildcard characters.
func (q *Query) ExpandWildCardPath(wildCardPath string) ([]string, error) {
if wildCardPath == "" {
Expand Down Expand Up @@ -209,8 +221,8 @@ func (q *Query) Close() error {
return PdhCloseQuery(q.Handle)
}

// matchInstanceName will check first for instance and then for any objects names.
func matchInstanceName(counterPath string) (string, error) {
// MatchInstanceName will check first for instance and then for any objects names.
func MatchInstanceName(counterPath string) (string, error) {
matches := instanceNameRegexp.FindStringSubmatch(counterPath)
if len(matches) != 2 {
matches = objectNameRegexp.FindStringSubmatch(counterPath)
Expand Down
46 changes: 46 additions & 0 deletions metricbeat/helper/windows/pdh/pdh_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
//sys _PdhExpandWildCardPath(dataSource *uint16, wildcardPath *uint16, expandedPathList *uint16, pathListLength *uint32) (errcode error) [failretval!=0] = pdh.PdhExpandWildCardPathW
//sys _PdhExpandCounterPath(wildcardPath *uint16, expandedPathList *uint16, pathListLength *uint32) (errcode error) [failretval!=0] = pdh.PdhExpandCounterPathW
//sys _PdhGetCounterInfo(counter PdhCounterHandle, text uint16, size *uint32, lpBuffer *byte) (errcode error) [failretval!=0] = pdh.PdhGetCounterInfoW
//sys _PdhEnumObjectItems(dataSource uint16, machineName uint16, objectName *uint16, counterList *uint16, counterListSize *uint32, instanceList *uint16, instanceListSize *uint32, detailLevel uint32, flags uint32) (errcode error) [failretval!=0] = pdh.PdhEnumObjectItemsW

type PdhQueryHandle uintptr

Expand All @@ -50,6 +51,9 @@ type PdhCounterHandle uintptr

var InvalidCounterHandle = ^PdhCounterHandle(0)

// counter detail level
narph marked this conversation as resolved.
Show resolved Hide resolved
const PerformanceDetailWizard = 400

// PdhCounterInfo struct contains the performance counter details
type PdhCounterInfo struct {
DwLength uint32
Expand Down Expand Up @@ -247,6 +251,48 @@ func PdhCloseQuery(query PdhQueryHandle) error {
return nil
}

// PdhEnumObjectItems returns the counters and instance info for given object
func PdhEnumObjectItems(objectName string) ([]uint16, []uint16, error) {
narph marked this conversation as resolved.
Show resolved Hide resolved
var (
cBuff = make([]uint16, 1)
cBuffSize = uint32(0)
iBuff = make([]uint16, 1)
iBuffSize = uint32(0)
)
obj := windows.StringToUTF16Ptr(objectName)
if err := _PdhEnumObjectItems(
0,
0,
obj,
&cBuff[0],
&cBuffSize,
&iBuff[0],
&iBuffSize,
PerformanceDetailWizard,
0); err != nil {
if PdhErrno(err.(syscall.Errno)) != PDH_MORE_DATA {
return nil, nil, PdhErrno(err.(syscall.Errno))
}
cBuff = make([]uint16, cBuffSize)
iBuff = make([]uint16, iBuffSize)

if err = _PdhEnumObjectItems(
0,
0,
obj,
&cBuff[0],
&cBuffSize,
&iBuff[0],
&iBuffSize,
PerformanceDetailWizard,
0); err != nil {
return nil, nil, err
}
return cBuff, iBuff, nil
}
return nil, nil, nil
}

// Error returns a more explicit error message.
func (e PdhErrno) Error() string {
// If the value is not one of the known PDH errors then assume its a
Expand Down
Loading