Menu
Grafana Cloud

Wildfly integration for Grafana Cloud

Wildfly is a modular & lightweight application server that handles deploying and managing several Java applications. The Wildfly integration uses the Grafana Agent to collect metrics and logs for monitoring a Wildfly instance. Including metrics for monitoring sessions, deployments, network traffic, and datasource connections. This also includes monitoring server log files of a Wildfly instance which provides valuable information for usage and operations of the instance.

This integration supports Wildfly 27.X onwards.

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

Before you begin

In order to collect metrics from Wildfly, ensure the metric subsystem is enabled by following the official documentation.

To enable session metrics, run the following command in the CLI:

bash
/subsystem=undertow:write-attribute(name=statistics-enabled,value=true)

To enable transaction metrics, run the following command in the CLI:

bash
/subsystem=transactions:write-attribute(name=statistics-enabled, value=true)

Wildfly has authentication enabled by default (for Wildfly management interfaces). This includes a simple username and password from an established user. To setup a user, simply run the add-user.sh script inside the Wildfly installation’s bin folder. Once script is complete, add your new <wildfly_user> and <wildfly_password> to the username and password fields underneath basic_auth. However, in the case that Wildlfly authentication is not enabled, basic_auth may need to be removed in your metrics config.

More info on user creation can be found here.

The CLI is launched using jboss-cli.sh or jboss-cli.bat located in the WildFly bin directory. For more information on default directory structure visit Getting Started Guide.

Next, connect to the WildFly instance. This is done by running connect command.

bash
./bin/jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server
or 'help' for the list of supported commands.
[disconnected /]

[disconnected /] connect
[domain@localhost:9990 /]

[domain@localhost:9990 /] quit
Closed connection to localhost:9990

To terminate the session type quit.

Install Wildfly integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find Wildfly and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Wildfly 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 Wildfly setup.

Configuration snippets for Grafana Alloy

Simple mode

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

First, manually copy and append the following snippets into your alloy configuration file.

Logs snippets

darwin

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

linux

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

windows

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

Advanced mode

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

To instruct Grafana Alloy to scrape your Wildfly instances, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

Advanced metrics snippets

alloy
discovery.relabel "metrics_integrations_integrations_wildfly" {
	targets = [{
		__address__ = "localhost:9990",
	}]

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

prometheus.scrape "metrics_integrations_integrations_wildfly" {
	targets    = discovery.relabel.metrics_integrations_integrations_wildfly.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/wildfly"

	basic_auth {
		username = "<wildfly_user>"
		password = "<wildfly_password>"
	}
}

To monitor your Wildfly instance, you must use a discovery.relabel component to discover your Wildfly Prometheus endpoint and apply appropriate labels, followed by a prometheus.scrape component to scrape it.

Configure the following properties within each discovery.relabel component:

  • __address__: The address to your Wildfly Prometheus metrics endpoint.
  • 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 Wildfly instance. Make sure this label value is the same for all telemetry data collected for this instance.

If you have multiple Wildfly servers to scrape, configure one discovery.relabel for each and scrape them by including each under targets within the prometheus.scrape component.

Advanced logs snippets

darwin

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

To monitor your Wildfly 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 Wildfly 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 Wildfly instance. Make sure this label value is the same for all telemetry data collected for this instance.
  • loki.process defines how to process logs before sending it to Loki.

  • loki.source.file sends logs to Loki.

linux

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

To monitor your Wildfly 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 Wildfly 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 Wildfly instance. Make sure this label value is the same for all telemetry data collected for this instance.
  • loki.process defines how to process logs before sending it to Loki.

  • loki.source.file sends logs to Loki.

windows

alloy
local.file_match "logs_integrations_integrations_wildfly" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/opt/wildfly/standalone/log/server.log",
		instance    = constants.hostname,
		job         = "integrations/wildfly",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+ \\d+:\\d+:\\d+,\\d+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

To monitor your Wildfly 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 Wildfly 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 Wildfly instance. Make sure this label value is the same for all telemetry data collected for this instance.
  • loki.process defines how to process logs before sending it to Loki.

  • loki.source.file sends logs to Loki.

Grafana Agent static configuration (deprecated)

The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.

Dashboards

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

  • Wildfly datasource
  • Wildfly overview

Wildfly overview

Wildfly overview

Wildfly overview (Sessions)

Wildfly overview (Sessions)

Wildfly datasource dashboard

Wildfly datasource dashboard

Alerts

The Wildfly integration includes the following useful alerts:

AlertDescription
HighPercentageOfErrorResponsesCritical: Large percentage of requests are resulting in 5XX responses.
HighNumberOfRejectedSessionsForDeploymentCritical: Large number of sessions are being rejected for a deployment.

Metrics

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

  • up
  • wildfly_batch_jberet_active_count
  • wildfly_datasources_pool_idle_count
  • wildfly_datasources_pool_in_use_count
  • wildfly_transactions_number_of_aborted_transactions_total
  • wildfly_transactions_number_of_inflight_transactions
  • wildfly_transactions_number_of_transactions_total
  • wildfly_undertow_active_sessions
  • wildfly_undertow_bytes_received_total_bytes
  • wildfly_undertow_bytes_sent_total_bytes
  • wildfly_undertow_error_count_total
  • wildfly_undertow_expired_sessions_total
  • wildfly_undertow_rejected_sessions_total
  • wildfly_undertow_request_count_total

Changelog

md
# 1.0.0 - May 2024

* Added cluster selector to dashboards for kubernetes support

# 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 Wildfly 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.