Menu
Grafana Cloud

Microsoft IIS integration for Grafana Cloud

Microsoft IIS is a web server that can host and manage web apps on Windows servers. This integration for Grafana Cloud allows users to collect metrics and access logs for monitoring a Microsoft IIS instance.

This integration supports Microsoft IIS 10.0 onwards.

This integration includes 5 useful alerts and 2 pre-built dashboards to help monitor and visualize Microsoft IIS metrics and logs.

Grafana Alloy configuration

Before you begin

In order for the integration to properly work, you must configure Microsoft IIS with the following:

Performance Counters need to be enabled

  1. Start Server Manager
  2. Navigate to the Local Server tab
  3. Scroll down to the Performance section
  4. Right click the server and select Start Performance Counters

You will also need to have a site running on your IIS instance to see some of the metrics.

Install Microsoft IIS integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find Microsoft IIS and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Microsoft IIS metrics and logs to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your Microsoft IIS setup.

Configuration snippets for Grafana Alloy

Simple mode

These snippets are configured to scrape a single Microsoft IIS instance running locally with default ports.

Copy and paste the following snippets into your Grafana Alloy configuration file.

Integrations snippets

river
prometheus.exporter.windows "integrations_windows_exporter" {
	enabled_collectors = ["iis"]

	dfsr {
		sources_enabled = [""]
	}

	exchange {
		enabled_list = [""]
	}

	mssql {
		enabled_classes = [""]
	}
}

discovery.relabel "integrations_windows_exporter" {
	targets = prometheus.exporter.windows.integrations_windows_exporter.targets

	rule {
		target_label = "job"
		replacement  = "integrations/iis"
	}

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "integrations_windows_exporter" {
	targets    = discovery.relabel.integrations_windows_exporter.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/windows_exporter"
}

Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your Microsoft IIS instances, copy and paste the snippets to your configuration file and follow subsequent instructions.

Advanced integrations snippets

river
prometheus.exporter.windows "integrations_windows_exporter" {
	enabled_collectors = ["iis"]

	dfsr {
		sources_enabled = [""]
	}

	exchange {
		enabled_list = [""]
	}

	mssql {
		enabled_classes = [""]
	}
}

discovery.relabel "integrations_windows_exporter" {
	targets = prometheus.exporter.windows.integrations_windows_exporter.targets

	rule {
		target_label = "job"
		replacement  = "integrations/iis"
	}

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "integrations_windows_exporter" {
	targets    = discovery.relabel.integrations_windows_exporter.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/windows_exporter"
}

This integrations uses the prometheus.exporter.windows component to generate metrics from a Microsoft IIS instance.

For the full array of configuration options, refer to the prometheus.exporter.windows component reference documentation.

This exporter must be linked with a discovery.relabel component to apply the necessary relabelings.

For each Microsoft IIS instance to be monitored you must create a pair of these components.

Configure the following properties within each discovery.relabel component:

  • instance label: constants.hostname sets the instance label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Microsoft IIS instance. Make sure this label value is the same for all telemetry data collected for this instance.

You can then scrape them by including each discovery.relabel under targets within the prometheus.scrape component.

Advanced logs snippets

windows

river
local.file_match "logs_integrations_integrations_iis" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/inetpub/logs/LogFiles/W3SVC<site1-id>/u_ex*.log",
		instance    = constants.hostname,
		job         = "integrations/iis",
		site        = "<your-site1-name>",
	}]
}

loki.process "logs_integrations_integrations_iis" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.match {
		selector            = "{job=\"integrations/iis\"} |~ \"^#\""
		action              = "drop"
		drop_counter_reason = "iis_comment_line"
	}
}

loki.source.file "logs_integrations_integrations_iis" {
	targets    = local.file_match.logs_integrations_integrations_iis.targets
	forward_to = [loki.process.logs_integrations_integrations_iis.receiver]
}

To monitor your Microsoft IIS instance logs, you will use a combination of the following components:

  • local.file_match defines where to find the log file to be scraped. Change the following properties according to your environment:

    • __address__: The Microsoft IIS instance address
    • __path__: The path to the log file.
    • instance label: constants.hostname sets the instance label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Microsoft IIS instance. Make sure this label value is the same for all telemetry data collected for this instance.
    • site label must be set to the website name that corresponds to the log path label __path__, which will contain a corresponding siteID. The siteID needs to bet set to a matching ID of the site label in the __path__. For example, a site name might be Default Website and its site ID might be 1. This would result in site: Default Website and __path__: /inetpub/logs/LogFiles/W3SVC1/u_ex*.log. For each site, a new static config must be appended to the list under static_configs in order to filter logs by their site labels.
  • loki.process defines how to process logs before sending it to Loki.

  • loki.source.file sends logs to Loki.

Grafana Agent configuration

Before you begin

In order for the integration to properly work, you must configure Microsoft IIS with the following:

Performance Counters need to be enabled

  1. Start Server Manager
  2. Navigate to the Local Server tab
  3. Scroll down to the Performance section
  4. Right click the server and select Start Performance Counters

You will also need to have a site running on your IIS instance to see some of the metrics.

Install Microsoft IIS integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find Microsoft IIS and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Microsoft IIS metrics and logs to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your Microsoft IIS setup.

Post-install configuration for the Microsoft IIS integration

Make sure to change targets in the logs snippet according to your environment.

You must configure custom labels for this integration: If you want to show logs and metrics signals correlated in your dashboards as a single pane of glass, ensure the following:

  • job and instance label values must match for the windows_exporter integration and logs scrape config in your agent configuration file.
  • job must be set to integrations/iis
  • instance label must be set to a value that uniquely identifies your Microsoft IIS instance. Please replace the default hostname value according to your environment - it should be set manually.
  • site label must be set to the website name that corresponds to the log path label __path__, which will contain a corresponding siteID. The siteID needs to bet set to a matching ID of the site label in the __path__. For example, a site name might be Default Website and its site ID might be 1. This would result in site: Default Website and __path__: /inetpub/logs/LogFiles/W3SVC1/u_ex*.log. For each site, a new static config must be appended to the list under static_configs in order to filter logs by their site labels.

Configuration snippets for Grafana Agent

Below integrations, insert the following lines and change the URLs according to your environment:

yaml
  windows_exporter:
    enabled: true
    instance: '<your-instance-name>'
    enabled_collectors: "iis"
    scrape_interval: 60s
    relabel_configs:
      - target_label: job
        replacement: 'integrations/iis'

Below logs.configs.scrape_configs, insert the following lines according to your environment.

yaml
    - job_name: integrations/iis
      static_configs:
        # In order to monitor site logs insert another
        # static_config like the sample below 
        - targets:
            - localhost
          labels:
            job: integrations/iis
            instance: '<your-instance-name>'
            site: '<your-site1-name>'
            __path__: /inetpub/logs/LogFiles/W3SVC<site1-id>/u_ex*.log
      pipeline_stages:
        - match:
          # Drop lines that are comments (start with #)
          selector: '{job="integrations/iis"} |~ "^#"'
          action: drop
          drop_counter_reason: iis_comment_line

Full example configuration for Grafana Agent

Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the Microsoft IIS integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.

yaml
integrations:
  prometheus_remote_write:
  - basic_auth:
      password: <your_prom_pass>
      username: <your_prom_user>
    url: <your_prom_url>
  agent:
    enabled: true
    relabel_configs:
    - action: replace
      source_labels:
      - agent_hostname
      target_label: instance
    - action: replace
      target_label: job
      replacement: "integrations/agent-check"
    metric_relabel_configs:
    - action: keep
      regex: (prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
      source_labels:
      - __name__
  # Add here any snippet that belongs to the `integrations` section.
  # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
  windows_exporter:
    enabled: true
    instance: '<your-instance-name>'
    enabled_collectors: "iis"
    scrape_interval: 60s
    relabel_configs:
      - target_label: job
        replacement: 'integrations/iis'
logs:
  configs:
  - clients:
    - basic_auth:
        password: <your_loki_pass>
        username: <your_loki_user>
      url: <your_loki_url>
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
      # Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
    - job_name: integrations/iis
      static_configs:
        # In order to monitor site logs insert another
        # static_config like the sample below 
        - targets:
            - localhost
          labels:
            job: integrations/iis
            instance: '<your-instance-name>'
            site: '<your-site1-name>'
            __path__: /inetpub/logs/LogFiles/W3SVC<site1-id>/u_ex*.log
      pipeline_stages:
        - match:
          # Drop lines that are comments (start with #)
          selector: '{job="integrations/iis"} |~ "^#"'
          action: drop
          drop_counter_reason: iis_comment_line
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: <your_prom_pass>
        username: <your_prom_user>
      url: <your_prom_url>
    scrape_configs:
      # Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal

Dashboards

The Microsoft IIS integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • Microsoft IIS applications
  • Microsoft IIS overview

Microsoft IIS overview

Microsoft IIS overview

Microsoft IIS overview (Traffic)

Microsoft IIS overview (Traffic)

Microsoft IIS applications

Microsoft IIS applications

Alerts

The Microsoft IIS integration includes the following useful alerts:

AlertDescription
MicrosoftIISHighNumberOfRejectedAsyncIORequestsWarning: There are a high number of rejected async I/O requests for a site.
MicrosoftIISHighNumberOf5xxRequestErrorsCritical: There are a high number of 5xx request errors for an application.
MicrosoftIISLowSuccessRateForWebsocketConnectionsCritical: There is a low success rate for websocket connections for an application.
MicrosoftIISThreadpoolUtilizationNearingMaxCritical: The thread pool utilization is nearing max capacity.
MicrosoftIISHighNumberOfWorkerProcessFailuresWarning: There are a high number of worker process failures for an application.

Metrics

The most important metrics provided by the Microsoft IIS integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

  • up
  • windows_iis_blocked_async_io_requests_total
  • windows_iis_connection_attempts_all_instances_total
  • windows_iis_current_application_pool_state
  • windows_iis_current_connections
  • windows_iis_current_worker_processes
  • windows_iis_files_received_total
  • windows_iis_files_sent_total
  • windows_iis_locked_errors_total
  • windows_iis_not_found_errors_total
  • windows_iis_received_bytes_total
  • windows_iis_rejected_async_io_requests_total
  • windows_iis_requests_total
  • windows_iis_sent_bytes_total
  • windows_iis_server_file_cache_hits_total
  • windows_iis_server_file_cache_queries_total
  • windows_iis_server_metadata_cache_hits_total
  • windows_iis_server_metadata_cache_queries_total
  • windows_iis_server_output_cache_hits_total
  • windows_iis_server_output_cache_queries_total
  • windows_iis_server_uri_cache_hits_total
  • windows_iis_server_uri_cache_queries_total
  • windows_iis_total_worker_process_failures
  • windows_iis_total_worker_process_ping_failures
  • windows_iis_total_worker_process_shutdown_failures
  • windows_iis_total_worker_process_startup_failures
  • windows_iis_worker_file_cache_hits_total
  • windows_iis_worker_file_cache_queries_total
  • windows_iis_worker_max_threads
  • windows_iis_worker_metadata_cache_hits_total
  • windows_iis_worker_metadata_cache_queries_total
  • windows_iis_worker_output_cache_hits_total
  • windows_iis_worker_output_queries_total
  • windows_iis_worker_request_errors_total
  • windows_iis_worker_requests_total
  • windows_iis_worker_threads
  • windows_iis_worker_uri_cache_hits_total
  • windows_iis_worker_uri_cache_queries_total
  • windows_iis_worker_websocket_connection_accepted_total
  • windows_iis_worker_websocket_connection_attempts_total

Changelog

md
# 0.0.3 - September 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.2 - August 2023

* Add regex filter for logs datasource

# 0.0.1 - April 2023

* Initial release

Cost

By connecting your Microsoft IIS instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.