WildFly 9 Access Logging - wildfly

I am trying to set up access logging using WildFly 9 in Domain mode. I have found a few resources which suggest using something like this in the domain.xml file:
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<access-log pattern="%A%t%h%l%u%r%s%b%T%I" directory="${jboss.server.log.dir}" prefix="access" suffix=".log"/>
</host>
I then restarted wildfly, but no logging is occurring and there are no errors in the wildfly start up, so I am just banging my head against the wall. I would really appreciate any help that anyone can provide.
Also is there a way to register access logging using the cli in domain mode?

There should be a way to add all resources in CLI for both domain mode and standalone. It's possible you're editing the wrong profile in the XML. Regardless using CLI is the preferred solution.
The first thing you need to know is which profile you're running under. You can determine by the server-group(s) running.
[domain#localhost:9990 /] /server-group=*:read-attribute(name=profile)
{
"outcome" => "success",
"result" => [
{
"address" => [("server-group" => "main-server-group")],
"outcome" => "success",
"result" => "full"
},
{
"address" => [("server-group" => "other-server-group")],
"outcome" => "success",
"result" => "full-ha"
}
]
}
We'll assume here we're using the main-server-group. You then need to add the access-log setting to the undertow subsystem.
/profile=full/subsystem=undertow/server=default-server/host=default-host/setting=access-log:add(pattern="%A%t%h%l%u%r%s%b%T%I", directory="${jboss.server.log.dir}", prefix=access, suffix=".log")
This will add access logging to all servers in that server-group. You will need to access a server via a web request before the log will be created. No restart or reload is required either.
One extra note too you can see what settings are available to the setting resource in undertow with the following command.
/profile=full/subsystem=undertow/server=default-server/host=default-host/setting=*:read-resource-description

If you need to log time taken to process the request, in seconds (format attribute %T) you should add additional parameter:
/profile=full/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=record-request-start-time,value=true)

Related

WFLYCTL0362: Capabilities required by resource '/subsystem=microprofile-metrics-smallrye' are not available:

I am trying to migrate WildFly 21 to 24 .
I have these errors in the console. Server can not running it is stopped.
14:11:19,550 ERROR [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0362: Capabilities required by resource '/subsystem=microprofile-health-smallrye' are not available:
org.wildfly.extension.health.http-context; There are no known registration points which can provide this capability.
org.wildfly.extension.health.server-probes; There are no known registration points which can provide this capability. 14:11:19,550 ERROR [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0362: Capabilities required by resource '/subsystem=microprofile-metrics-smallrye' are not available:
org.wildfly.extension.metrics.http-context; There are no known registration points which can provide this capability.
I have added metrics and health extensions to standalone xmls
<extension module="org.wildfly.extension.microprofile.health-smallrye"/>
<extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>
<subsystem xmlns="urn:wildfly:microprofile-health-smallrye:2.0" security-enabled="false" empty-liveness-checks-status="${env.MP_HEALTH_EMPTY_LIVENESS_CHECKS_STATUS:UP}" empty-readiness-checks-status="${env.MP_HEALTH_EMPTY_READINESS_CHECKS_STATUS:UP}"/>
<subsystem xmlns="urn:wildfly:microprofile-metrics-smallrye:2.0" security-enabled="false" exposed-subsystems="*" prefix="${wildfly.metrics.prefix:wildfly}"/>
but for main configuration file I am using a different xml.
I saw in another questions using jboss.cli to add these extensions but jboss cli is not connecting because server can not running currently.
Do you have any suggestions or advices ?
Thanks.
You can still use CLI in "offline" mode to add the extension. First simply enter a CLI session with:
$JBOSS_HOME/bin/jboss-cli.sh
Then you can start the embedded server to make your changes.
embed-server
You should end up seeing something like this:
[disconnected /] embed-server
[standalone#embedded /]
From here you can enter CLI commands like:
/extension=org.wildfly.extension.microprofile.health-smallrye:add
/extension=org.wildfly.extension.microprofile.metrics-smallrye:add
/subsystem=microprofile-health-smallrye:add(security-enabled=false, empty-liveness-checks-status="${env.MP_HEALTH_EMPTY_LIVENESS_CHECKS_STATUS:UP}", empty-readiness-checks-status="${env.MP_HEALTH_EMPTY_READINESS_CHECKS_STATUS:UP}")
The output should look something like:
[standalone#embedded /] /extension=org.wildfly.extension.microprofile.health-smallrye:add
{"outcome" => "success"}
[standalone#embedded /] /extension=org.wildfly.extension.microprofile.metrics-smallrye:add
{"outcome" => "success"}
[standalone#embedded /] /subsystem=microprofile-health-smallrye:add(security-enabled=false, empty-liveness-checks-status="${env.MP_HEALTH_EMPTY_LIVENESS_CHECKS_STATUS:UP}", empty-readiness-checks-status="${env.MP_HEALTH_EMPTY_READINESS_CHECKS_STATUS:UP}")
{"outcome" => "success"}
Then you can just exit CLI.
I found out microprofile.health-smallrye and microprofile.metrics-smallrye are not supported in WildFly 24. You should use subsystem=metrics,subsystem=health.
If you look into this in detail check here.

Can not create jms-queue in wildfly using jboss-cli

I started wildfly 24 server with standalone-full.xml profile, when i run following command in jboss-cli to create jms-queue i get following error
[standalone#localhost:9990 /] jms-queue --profile=full add --queue-address=foo --entries=["java:/jms/queue/foo"]
WFLYCTL0175: Resource [
("subsystem" => "messaging-activemq"),
("server" => "default")
] does not exist; a resource at address [
("subsystem" => "messaging-activemq"),
("server" => "default"),
("jms-queue" => "foo")
] cannot be created until all ancestor resources have been added
What am i missing here? Any reference docs to create the jms server, queues?
Update:
I tried to create the server using web console first
And it filed with the required capabilities are not available, any documentation refernece that indicates what are the required capabilities i need to added prior configuring JMS
Yes don't use the profile parameter which is used in domain mode.
jms-queue add --queue-address=foo --entries=["java:/jms/queue/foo"]
works properly.
The issue is i was using wildfly "WildFly Preview EE 9.1 Distribution" the correct verirsion is "Jakarta EE 8 Full & Web Distribution"

Wildfly Management CLI Configuration

I've been finding ways to load configuration to wildfly in bulk (say I have a json data).
Something that kind of look like this.
./jboss-cli.sh -c subsystem=messagingactivemq/server=default:add(<data.json>)
Where <data.json>
{
"outcome" => "success",
"result" => {
"address-full-policy" => "BLOCK",
"dead-letter-address" => "jms.queue.DLQ",
"expiry-address" => "jms.queue.ExpiryQueue",
"last-value-queue" => false,
"max-delivery-attempts" => 10,
"max-size-bytes" => 12333,
"message-counter-history-day-limit" => 10,
"page-max-cache-size" => 5,
"page-size-bytes" => 12333,
"redelivery-delay" => 0,
"redistribution-delay" => 222L,
"send-to-dla-on-no-route" => false
}
}
I want to load the above json directly to wildlfy via jboss-cli. Is this even possible? i have been looking for references about this for the past weeks. Any inputs are welcome.
EDITED
Just to be clear with my goals, I am trying ti migrate manually configured items on jBoss AS7.1 into Wildfly 10.1. Currently migration scripts only supports EAP versions of jBoss. So I have to manually select configurations fron jBoss to be migrated to wildfly. Yes, there are configuration that are deprecated and/or deleted in wildfly, so between jBoss AS7.1 and Wildfly10.1 I have to make some changes to the configuration before I load it to wildfly hence I mentioned the json data.
Since when I try to outputresource in jBoss AS7.1 via jboss-cli.sh using command /subsystem=messaging/hornetq-server=default:read-resource it will output something like
{
"outcome" => "success",
"result" => {
"acceptor" => undefined,
"allow-failback" => true,
"async-connection-execution-enabled" => true,
"backup" => false,
"bridge" => undefined,
"broadcast-group" => undefined,
"cluster-connection" => undefined,
... some resource ....
So I will make some modification on the above data (since wildfly uses activemq) and load it to wildfly as activemq. But it just want to use the json data and load it directly to wildfly's jboss-cli.sh. I want to automate this and just execute a script (shell) to do the migration.
Not entirely sure, what exactly are you trying to achieve here, but if you want to execute bulk operations from file, you can use jboss-cli.sh --file=commands.cli where commands.cli is a text file containing jboss cli commands.
This way you can perform multiple operations at once, plus you can utilize the batch functionality provided by JBoss CLI to make sure all changes are applied or reverted.
Example file with multiple commands:
#Add xa datasource
xa-data-source add \
--name=my.app.ds \
--jndi-name=java:jboss/datasources/my.app.ds \
--driver-name=h2 \
--user-name=username \
--password=password \
--use-java-context=true \
--enabled=true \
--xa-datasource-properties={"URL"=>"jdbc:h2:tcp://${env.DB_HOST:localhost}:${env.DB_PORT:1521}/~/my.app.ds;MVCC=TRUE"}
#Add JMS queue
jms-queue add --queue-address=foo.bar.myapp.queue --entries=java:/jms/queue/foo.bar.myapp.queue
#Add system property
/system-property=ENABLE_MY_COOL_MESSAGING_FEATURE:add(value="true")
If you want to define modules or execute operations based on JSON file or any other format apart from the CLI command format, I am afraid you are out of luck. You can make you own java library that wraps the JBoss CLI to execute it though - as JBoss/Wildfly provides CLI bindings for Java and Python I believe.

JBoss EAP 7.0.5 can not add https-listener

I am adding a new security realm and https-listener with CLI:
/core-service=management/security-realm=HTTPSRealm/:add
/core-service=management/security-realm=HTTPSRealm/server-identity=ssl:add(alias=ssl,keystore-path="/path/to/configuration/testCA.jks", keystore-password="12345678")
reload
/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding="proxy-https", security-realm="HTTPSRealm")
At the last step I only get this:
{
"outcome" => "failed",
"failure-description" => undefined,
"rolled-back" => true
}
I already tried every solution I could find here. (running as batch etc)
Edit:
The listener config is added like this:
/socket-binding-group=standard-sockets/socket-binding=proxy-http:add(port=9080)
/socket-binding-group=standard-sockets/socket-binding=proxy-https:add(port=9443)
Have you created socket bindings for proxy-https ? The default binding is https. Try with it
/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding=https, security-realm=HTTPSRealm)

JBoss AS7: How to read datasource pool statistics with JMX

In JBossAS4, the MBean jboss.jca.ManagedConnectionPool allows to access, e.g., the number of used and the number of available connections of a data source. This MBean is no longer available in JBossAS7.
How can these values be accessed in JBossAS7? There seems to be a way: the JBoss Adminstration Console offers the values.
OK on windows or Linux you can can use Jboss cli (client interface).
This is on JBOSS AS 7.1.3
On my windows box this is what I did (My jboss home is C:\jboss-eap-6.0)
Execute the following batch file
C:\jboss-eap-6.0\bin\jboss-cli.bat
It will take you to a prompt
[disconnected /]
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands
.
Now type connect. for all other command try help. This will allow you to browse the JMX tree (May be my terminology may be wrong).
[disconnected /]connect
[standalone#rama-local:9999]
Lets say my data pool name is "OracleSampleDS"
Then you can query the stats by using below command
/subsystem=datasources/data-source=OracleSampleDS/statistics=pool:read-resource(include-runtime=true)
Here is the output I got
{
"outcome" => "success",
"result" => {
"ActiveCount" => "0",
"AvailableCount" => "20",
"AverageBlockingTime" => "0",
"AverageCreationTime" => "0",
"CreatedCount" => "0",
"DestroyedCount" => "0",
"MaxCreationTime" => "0",
"MaxUsedCount" => "0",
"MaxWaitTime" => "0",
"TimedOut" => "0",
"TotalBlockingTime" => "0",
"TotalCreationTime" => "0"
}
}
In case you changed the hostname during jboss installation to anything other than localhost you can edit jboss-cli.xml
I tried the same command on linux by using jboss-cl.sh
In case you have separate profile (mostly if you use domain mode) then specify the profile name as below.
/profile=full-ha/subsystem=datasources/data-source=OracleSampleDS/statistics=jdbc:read-resource(include-runtime=true)
Here the profile I was using in domain mode was "full-ha"
Once you are connected to the Jboss command line tool you can use few commands like
ls
pwn
connect
quit
(Try it out)
Also there is
http://loclahost:9990/management/subsystem/datasources/data-source/OracleSampleDS/statistics/pool?include-runtime=true
The ports my differ please see your hosts.xml (in case you are using domain mode)
or standalone.xml to see which management ports you have exposed by checking
Look at the section that says http-interface security-realm="ManagementRealm"
There is a MBean jboss.as:subsystem=datasources,xa-data-source=DATASOURCENAME_Pool which has all of the configuration attributes, but it does not feature statistics. According to this thread, the statistics are only exposed to the management API (http access with JSON export).