Liberty接続プールメトリック取得(mpMetrics)

LibertyからDb2に接続するアプリを稼働した際、Liberty接続プール数がどのように変動しているのか把握するため、メトリックを取得しました。
取得方法と出力結果を自分用のメモとして記録します。


### 取得できるデータ
接続プール関連のベンダー・メトリックとしては以下のような項目を取得可能です。
この一覧自体は[マニュアル](https://www.ibm.com/docs/ja/was-liberty/base?topic=metrics-microprofile-11-vendor)より引用していますが、一部説明文が英語になっている項目についてはマニュアルに記載がないため追加したもので、説明文はPrometheus形式で取得できたHelpの文言をそのまま転記したものです。

カウンター名(%s)にはデータソースJNDI名が含まれ、「jdbc/sample」というデータソースであれば「jdbc_sample」となります。
例) jdbc/sampleというJNDI名を持つデータソースの1つ目のカウンタの名前は「connectionpool.jdbc_sample.create.total」

| カウンター名 | 単位 | 説明 | 
|:-|:-|:-|
| connectionpool.%s.create.total  |   | プールの作成以降に作成された管理接続の総数。  | 
| connectionpool.%s.destroy.total  |   | プールの作成以降に破棄された管理接続の総数。  |
| connectionpool.%s.managedConnections  |   | 空きプール、共有プール、および非共有プール内の管理接続の数。  |
| connectionpool.%s.connectionHandles  |   | 使用中の接続の数。 この数には、単一の管理接続から共有される複数の接続も含まれる場合があります。  |
| connectionpool.%s.freeConnections  |   | 空きプール内の管理接続の数。  |
| connectionpool.%s.waitTime.total  | ミリ秒  |サーバーの開始以降の、すべての接続要求の待機時間の合計。   |
| connectionpool.%s.queuedRequests.total  |   |サーバーの開始以降の、接続プールがいっぱいであるために待機しなければならなかった接続要求の総数。   |
| connectionpool.%s.inUseTime.total  | ミリ秒  | サーバーの開始以降の、すべての接続が使用中である時間の合計。  |
| connectionpool.%s.usedConnections.total  |   | サーバーの開始以降の、接続プールがいっぱいであるために待機したか、待機の必要がなかった接続要求の総数。 現在使用中の接続は、この総数に含まれません。  |
|connectionpool.%s.usedConnections.total||The total number of connection requests that waited because of a full connection pool or did not have to wait since the start of the server. Any connections that are currently in use are not included in this total.|


https://www.ibm.com/docs/ja/was-liberty/base?topic=metrics-microprofile-11-vendor


### メトリックの取得形式
以下2つどちらかを選択可能です。
リクエスト時にAcceptヘッダ「application/json」を指定すると、JSON形式として取得されます。カウンター名の綴りが微妙に変わるんですね。

| フォーマット |取得されるmetricのカウンター名の書式(例)  |  
|:-|:-|
|Prometheus形式   |vendor:connectionpool_\<JNDI名(アンダーバー区切り)>___managed_connections__   |
|JSON形式   |connectionpool.\<JNDI名(アンダーバー区切り)>.__managedConnections__  |


### メトリック取得 – 設定

#### 環境
 * WebSphere Application Server 22.0.0.7 (wlp-1.0.66.cl220720220620-2217)
 * JDBC Driver: IBM Data Server Driver for JDBC and SQLJ 4.31.10
 * Db2 Server: Db2 11.5.7.0
 * (上記いずれも、IaaS上の非コンテナ環境)

#### 設定
##### (1) mpMetricsモジュールのインストール
よくわからずmpmetrics-1.0を入れてしまいました。
最終的にserver.xmlで指定したのはmpmetrics-1.1でしたが、特に支障はありませんでした。
```
# ./bin/installUtility install mpmetrics-1.0
Establishing a connection to the configured repositories ...
This process might take several minutes to complete.

Successfully connected to all configured repositories.

Preparing assets for installation. This process might take several minutes to complete.
Step 1 of 22: Downloading servlet-3.0 ...
Step 2 of 22: Installing servlet-3.0 ...
Step 3 of 22: Downloading servlet-3.1 ...
Step 4 of 22: Installing servlet-3.1 ...
Step 5 of 22: Downloading cdi-1.2 ...
Step 6 of 22: Installing cdi-1.2 ...
Step 7 of 22: Downloading mpMetrics-1.0 ...
Step 8 of 22: Installing mpMetrics-1.0 ...
Step 9 of 22: Downloading jaxrsClient-2.0 ...
Step 10 of 22: Installing jaxrsClient-2.0 ...
Step 11 of 22: Downloading jaxrs-1.1 ...
Step 12 of 22: Installing jaxrs-1.1 ...
Step 13 of 22: Downloading restConnector-1.0 ...
Step 14 of 22: Installing restConnector-1.0 ...
Step 15 of 22: Downloading jaxrs-2.0 ...
Step 16 of 22: Installing jaxrs-2.0 ...
Step 17 of 22: Downloading jsp-2.2 ...
Step 18 of 22: Installing jsp-2.2 ...
Step 19 of 22: Downloading jsonp-1.0 ...
Step 20 of 22: Installing jsonp-1.0 ...
Step 21 of 22: Validating installed fixes ...
Step 22 of 22: Cleaning up temporary files ...


All assets were successfully installed.

Start product validation...
Product validation completed successfully.
#

```
##### (2) server.xml編集
以下をserver.xmlに追記。
(メトリック取得に必要なエレメントのみ。今回利用したserver.xmlファイル全体は末尾に記載)

```xml
<featureManager>
    <feature>mpMetrics-1.1</feature>
    <feature>monitor-1.0</feature>
</featureManager>

<keyStore id="defaultKeyStore" location="myKeyStore.p12" password="yourPassword" type="PKCS12"/>
<mpMetrics authentication="false"/>
```

テスト環境で取得するのであくまでも最低限の、簡易的な設定です。

 * SSL証明書は、keyStoreエレメントを定義することによりLibertyが自動作成したものをそのまま利用
 * Basic認証(ユーザーログイン)なし


### メトリック取得 – 出力結果

:::note info
Libertyのメトリックでは、それまでに利用されたコンポーネントに関するメタデータのみ、出力されます。よって、Liberty起動後、一度もDBアクセスしない状態でメトリックを取得しても、接続プール関連の出力はなされません。
一度DBアクセスを行うアプリケーションを動かした後に取得します。
:::


#### Prometheus 形式
curlコマンドで取得してみます。
URLを/metrics/vendor に変更すると、vendorの出力のみに絞られますが、今回はとりあえず全部取得。

```text:metric取得
$ date ; curl -k https://hostname:19443/metrics
```


```text:出力(Prometheus 形式)
Thu Oct 12 20:24:05 JST 2023
# TYPE base:classloader_total_loaded_class_count counter
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution.
base:classloader_total_loaded_class_count 11915
# TYPE base:gc_global_count counter
# HELP base:gc_global_count Displays the total number of collections that have occurred. This attribute lists -1 if the collection count is undefined for this collector.
base:gc_global_count 3
# TYPE base:cpu_system_load_average gauge
# HELP base:cpu_system_load_average Displays the system load average for the last minute. The system load average is the sum of the number of runnable entities queued to the available processors and the number of runnable entities running on the available processors averaged over a period of time. The way in which the load average is calculated is operating system specific but is typically a damped time-dependent average. If the load average is not available, a negative value is displayed. This attribute is designed to provide a hint about the system load and may be queried frequently. The load average may be unavailable on some platform where it is expensive to implement this method.
base:cpu_system_load_average 0.08
# TYPE base:thread_count counter
# HELP base:thread_count Displays the current number of live threads including both daemon and non-daemon threads.
base:thread_count 47
# TYPE base:classloader_current_loaded_class_count counter
# HELP base:classloader_current_loaded_class_count Displays the number of classes that are currently loaded in the Java virtual machine.
base:classloader_current_loaded_class_count 11913
# TYPE base:gc_scavenge_time_seconds gauge
# HELP base:gc_scavenge_time_seconds Displays the approximate accumulated collection elapsed time in milliseconds. This attribute displays -1 if the collection elapsed time is undefined for this collector. The Java virtual machine implementation may use a high resolution timer to measure the elapsed time. This attribute may display the same value even if the collection count has been incremented if the collection elapsed time is very short.
base:gc_scavenge_time_seconds 7.546
# TYPE base:jvm_uptime_seconds gauge
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
base:jvm_uptime_seconds 115631.043
# TYPE base:memory_committed_heap_bytes gauge
# HELP base:memory_committed_heap_bytes Displays the amount of memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
base:memory_committed_heap_bytes 5.7540608E7
# TYPE base:thread_max_count counter
# HELP base:thread_max_count Displays the peak live thread count since the Java virtual machine started or peak was reset. This includes daemon and non-daemon threads.
base:thread_max_count 51
# TYPE base:cpu_available_processors gauge
# HELP base:cpu_available_processors Displays the number of processors available to the Java virtual machine. This value may change during a particular invocation of the virtual machine.
base:cpu_available_processors 2
# TYPE base:thread_daemon_count counter
# HELP base:thread_daemon_count Displays the current number of live daemon threads.
base:thread_daemon_count 44
# TYPE base:gc_scavenge_count counter
# HELP base:gc_scavenge_count Displays the total number of collections that have occurred. This attribute lists -1 if the collection count is undefined for this collector.
base:gc_scavenge_count 3004
# TYPE base:classloader_total_unloaded_class_count counter
# HELP base:classloader_total_unloaded_class_count Displays the total number of classes unloaded since the Java virtual machine has started execution.
base:classloader_total_unloaded_class_count 2
# TYPE base:memory_max_heap_bytes gauge
# HELP base:memory_max_heap_bytes Displays the maximum amount of heap memory in bytes that can be used for memory management. This attribute displays -1 if the maximum heap memory size is undefined. This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.
base:memory_max_heap_bytes 5.36870912E8
# TYPE base:cpu_process_cpu_load_percent gauge
# HELP base:cpu_process_cpu_load_percent Displays the 'recent cpu usage' for the Java Virtual Machine process.
base:cpu_process_cpu_load_percent 0.15207517422408373
# TYPE base:memory_used_heap_bytes gauge
# HELP base:memory_used_heap_bytes Displays the amount of used heap memory in bytes.
base:memory_used_heap_bytes 4.7604752E7
# TYPE base:gc_global_time_seconds gauge
# HELP base:gc_global_time_seconds Displays the approximate accumulated collection elapsed time in milliseconds. This attribute displays -1 if the collection elapsed time is undefined for this collector. The Java virtual machine implementation may use a high resolution timer to measure the elapsed time. This attribute may display the same value even if the collection count has been incremented if the collection elapsed time is very short.
base:gc_global_time_seconds 0.074
# TYPE vendor:connectionpool_jdbc_sample_connection_handles gauge
# HELP vendor:connectionpool_jdbc_sample_connection_handles The number of connections that are in use. This number might include multiple connections that are shared from a single managed connection.
vendor:connectionpool_jdbc_sample_connection_handles 0
# TYPE vendor:session_default_host_metrics_live_sessions gauge
# HELP vendor:session_default_host_metrics_live_sessions The number of users that are currently logged in.
vendor:session_default_host_metrics_live_sessions 0
# TYPE vendor:session_default_host_jdbc_sample_web_active_sessions gauge
# HELP vendor:session_default_host_jdbc_sample_web_active_sessions The number of concurrently active sessions. (A session is active if the product is currently processing a request that uses that user session).
vendor:session_default_host_jdbc_sample_web_active_sessions 0
# TYPE vendor:connectionpool_jdbc_sample_used_connections_total counter
# HELP vendor:connectionpool_jdbc_sample_used_connections_total The total number of connection requests that waited because of a full connection pool or did not have to wait since the start of the server. Any connections that are currently in use are not included in this total.
vendor:connectionpool_jdbc_sample_used_connections_total 1
# TYPE vendor:servlet_jdbc_sample_sample_jdbc_servlet_response_time_total_seconds gauge
# HELP vendor:servlet_jdbc_sample_sample_jdbc_servlet_response_time_total_seconds The total response time of this servlet since the start of the server.
vendor:servlet_jdbc_sample_sample_jdbc_servlet_response_time_total_seconds 0.10616697000000001
# TYPE vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_request_total counter
# HELP vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_request_total The number of visits to this servlet since the start of the server.
vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_request_total 12
# TYPE vendor:session_default_host_jdbc_sample_web_invalidatedby_timeout_total counter
# HELP vendor:session_default_host_jdbc_sample_web_invalidatedby_timeout_total The number of sessions that have logged out by timeout since this metric was enabled.
vendor:session_default_host_jdbc_sample_web_invalidatedby_timeout_total 0
# TYPE vendor:threadpool_default_executor_active_threads gauge
# HELP vendor:threadpool_default_executor_active_threads The number of threads that are running tasks.
vendor:threadpool_default_executor_active_threads 1
# TYPE vendor:session_default_host_jdbc_sample_web_live_sessions gauge
# HELP vendor:session_default_host_jdbc_sample_web_live_sessions The number of users that are currently logged in.
vendor:session_default_host_jdbc_sample_web_live_sessions 1
# TYPE vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_response_time_total_seconds gauge
# HELP vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_response_time_total_seconds The total response time of this servlet since the start of the server.
vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_response_time_total_seconds 0.09531460700000001
# TYPE vendor:servlet_jdbc_sample_sample_jdbc_servlet_request_total counter
# HELP vendor:servlet_jdbc_sample_sample_jdbc_servlet_request_total The number of visits to this servlet since the start of the server.
vendor:servlet_jdbc_sample_sample_jdbc_servlet_request_total 1
# TYPE vendor:connectionpool_jdbc_sample_destroy_total counter
# HELP vendor:connectionpool_jdbc_sample_destroy_total The total number of managed connections that have been destroyed since the pool creation.
vendor:connectionpool_jdbc_sample_destroy_total 0
# TYPE vendor:session_default_host_metrics_invalidated_total counter
# HELP vendor:session_default_host_metrics_invalidated_total The number of sessions that have logged out since this metric was enabled.
vendor:session_default_host_metrics_invalidated_total 1
# TYPE vendor:connectionpool_jdbc_sample_free_connections gauge
# HELP vendor:connectionpool_jdbc_sample_free_connections The number of managed connections in the free pool.
vendor:connectionpool_jdbc_sample_free_connections 1
# TYPE vendor:connectionpool_jdbc_sample_queued_requests_total counter
# HELP vendor:connectionpool_jdbc_sample_queued_requests_total The total number of connection requests that had to wait for a connection because of a full connection pool since the start of the server.
vendor:connectionpool_jdbc_sample_queued_requests_total 0
# TYPE vendor:session_default_host_jdbc_sample_web_invalidated_total counter
# HELP vendor:session_default_host_jdbc_sample_web_invalidated_total The number of sessions that have logged out since this metric was enabled.
vendor:session_default_host_jdbc_sample_web_invalidated_total 0
# TYPE vendor:connectionpool_jdbc_sample_create_total counter
# HELP vendor:connectionpool_jdbc_sample_create_total The total number of managed connections that have been created since the pool creation.
vendor:connectionpool_jdbc_sample_create_total 1
# TYPE vendor:session_default_host_metrics_active_sessions gauge
# HELP vendor:session_default_host_metrics_active_sessions The number of concurrently active sessions. (A session is active if the product is currently processing a request that uses that user session).
vendor:session_default_host_metrics_active_sessions 0
# TYPE vendor:session_default_host_jdbc_sample_web_create_total gauge
# HELP vendor:session_default_host_jdbc_sample_web_create_total The number of sessions that have logged in since this metric was enabled.
vendor:session_default_host_jdbc_sample_web_create_total 1
# TYPE vendor:session_default_host_metrics_invalidatedby_timeout_total counter
# HELP vendor:session_default_host_metrics_invalidatedby_timeout_total The number of sessions that have logged out by timeout since this metric was enabled.
vendor:session_default_host_metrics_invalidatedby_timeout_total 1
# TYPE vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_response_time_total_seconds gauge
# HELP vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_response_time_total_seconds The total response time of this servlet since the start of the server.
vendor:servlet_com_ibm_ws_microprofile_metrics_public_public_metrics_rest_proxy_servlet_response_time_total_seconds 0.295498881
# TYPE vendor:connectionpool_jdbc_sample_wait_time_total_seconds gauge
# HELP vendor:connectionpool_jdbc_sample_wait_time_total_seconds The total wait time on all connection requests since the start of the server.
vendor:connectionpool_jdbc_sample_wait_time_total_seconds 0.0
# TYPE vendor:session_default_host_metrics_create_total gauge
# HELP vendor:session_default_host_metrics_create_total The number of sessions that have logged in since this metric was enabled.
vendor:session_default_host_metrics_create_total 1
# TYPE vendor:threadpool_default_executor_size gauge
# HELP vendor:threadpool_default_executor_size The size of the thread pool.
vendor:threadpool_default_executor_size 4
# TYPE vendor:connectionpool_jdbc_sample_managed_connections gauge
# HELP vendor:connectionpool_jdbc_sample_managed_connections The number of managed connections in the free, shared, and unshared pools.
vendor:connectionpool_jdbc_sample_managed_connections 1
# TYPE vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_request_total counter
# HELP vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_request_total The number of visits to this servlet since the start of the server.
vendor:servlet_jdbc_sample_jdbc_sample_output_jsp_request_total 1
# TYPE vendor:connectionpool_jdbc_sample_in_use_time_total_seconds gauge
# HELP vendor:connectionpool_jdbc_sample_in_use_time_total_seconds The total time that all connections are in use since the start of the server.
vendor:connectionpool_jdbc_sample_in_use_time_total_seconds 0.091
```

#### JSON形式
curlコマンドオプションとしてAcceptヘッダを追加するとJSON形式で取得できます。

```text:metric取得
$ date ; curl -k --header "accept: application/json" https://hostname:19443/metrics
```

```json: 出力(JSON形式)
Thu Oct 12 20:26:08 JST 2023
{"vendor":{"connectionpool.jdbc_sample.connectionHandles":0,"session.default_host_metrics.liveSessions":0,"session.default_host_JDBCSampleWeb.activeSessions":0,"connectionpool.jdbc_sample.usedConnections.total":1,"servlet.JDBCSample_SampleJDBCServlet.responseTime.total":1.0616697E8,"servlet.com_ibm_ws_microprofile_metrics_public_PublicMetricsRESTProxyServlet.request.total":13,"session.default_host_JDBCSampleWeb.invalidatedbyTimeout.total":0,"threadpool.Default_Executor.activeThreads":1,"session.default_host_JDBCSampleWeb.liveSessions":1,"servlet.JDBCSample__JDBCSampleOutput_jsp.responseTime.total":9.5314607E7,"servlet.JDBCSample_SampleJDBCServlet.request.total":1,"connectionpool.jdbc_sample.destroy.total":0,"session.default_host_metrics.invalidated.total":1,"connectionpool.jdbc_sample.freeConnections":1,"connectionpool.jdbc_sample.queuedRequests.total":0,"session.default_host_JDBCSampleWeb.invalidated.total":0,"connectionpool.jdbc_sample.create.total":1,"session.default_host_metrics.activeSessions":0,"session.default_host_JDBCSampleWeb.create.total":1,"session.default_host_metrics.invalidatedbyTimeout.total":1,"servlet.com_ibm_ws_microprofile_metrics_public_PublicMetricsRESTProxyServlet.responseTime.total":4.9825844E8,"connectionpool.jdbc_sample.waitTime.total":0.0,"session.default_host_metrics.create.total":1,"threadpool.Default_Executor.size":4,"connectionpool.jdbc_sample.managedConnections":1,"servlet.JDBCSample__JDBCSampleOutput_jsp.request.total":1,"connectionpool.jdbc_sample.inUseTime.total":91.0},"base":{"classloader.totalLoadedClass.count":11937,"gc.global.count":3,"cpu.systemLoadAverage":0.01,"thread.count":47,"classloader.currentLoadedClass.count":11935,"gc.scavenge.time":7570,"jvm.uptime":115753696,"memory.committedHeap":57540608,"thread.max.count":51,"cpu.availableProcessors":2,"thread.daemon.count":44,"gc.scavenge.count":3008,"classloader.totalUnloadedClass.count":2,"memory.maxHeap":536870912,"cpu.processCpuLoad":0.022564783125331188,"memory.usedHeap":43572032,"gc.global.time":74}}
```

```json: 出力(JSON形式、整形)
{
    "vendor": {
        "connectionpool.jdbc_sample.connectionHandles": 0,
        "session.default_host_metrics.liveSessions": 0,
        "session.default_host_JDBCSampleWeb.activeSessions": 0,
        "connectionpool.jdbc_sample.usedConnections.total": 1,
        "servlet.JDBCSample_SampleJDBCServlet.responseTime.total": 1.0616697E8,
        "servlet.com_ibm_ws_microprofile_metrics_public_PublicMetricsRESTProxyServlet.request.total": 13,
        "session.default_host_JDBCSampleWeb.invalidatedbyTimeout.total": 0,
        "threadpool.Default_Executor.activeThreads": 1,
        "session.default_host_JDBCSampleWeb.liveSessions": 1,
        "servlet.JDBCSample__JDBCSampleOutput_jsp.responseTime.total": 9.5314607E7,
        "servlet.JDBCSample_SampleJDBCServlet.request.total": 1,
        "connectionpool.jdbc_sample.destroy.total": 0,
        "session.default_host_metrics.invalidated.total": 1,
        "connectionpool.jdbc_sample.freeConnections": 1,
        "connectionpool.jdbc_sample.queuedRequests.total": 0,
        "session.default_host_JDBCSampleWeb.invalidated.total": 0,
        "connectionpool.jdbc_sample.create.total": 1,
        "session.default_host_metrics.activeSessions": 0,
        "session.default_host_JDBCSampleWeb.create.total": 1,
        "session.default_host_metrics.invalidatedbyTimeout.total": 1,
        "servlet.com_ibm_ws_microprofile_metrics_public_PublicMetricsRESTProxyServlet.responseTime.total": 4.9825844E8,
        "connectionpool.jdbc_sample.waitTime.total": 0.0,
        "session.default_host_metrics.create.total": 1,
        "threadpool.Default_Executor.size": 4,
        "connectionpool.jdbc_sample.managedConnections": 1,
        "servlet.JDBCSample__JDBCSampleOutput_jsp.request.total": 1,
        "connectionpool.jdbc_sample.inUseTime.total": 91.0
    },
    "base": {
        "classloader.totalLoadedClass.count": 11937,
        "gc.global.count": 3,
        "cpu.systemLoadAverage": 0.01,
        "thread.count": 47,
        "classloader.currentLoadedClass.count": 11935,
        "gc.scavenge.time": 7570,
        "jvm.uptime": 115753696,
        "memory.committedHeap": 57540608,
        "thread.max.count": 51,
        "cpu.availableProcessors": 2,
        "thread.daemon.count": 44,
        "gc.scavenge.count": 3008,
        "classloader.totalUnloadedClass.count": 2,
        "memory.maxHeap": 536870912,
        "cpu.processCpuLoad": 0.022564783125331188,
        "memory.usedHeap": 43572032,
        "gc.global.time": 74
    }
}
```

### 補足

#### 検証実行時のserver.xml（全体）

```xml:server.xml
<server description="liberty1">

<!-- Enable features -->
<featureManager>
    <feature>webProfile-8.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>mpMetrics-1.1</feature>
    <feature>monitor-1.0</feature>
</featureManager>

<keyStore id="defaultKeyStore" location="myKeyStore.p12" password="yourPassword" type="PKCS12"/>
<mpMetrics authentication="false"/>


<logging traceSpecification="*=info:WAS.j2c=all:RRA=all:Transaction=all" maxFileSize="1000" maxFiles="50"/>

<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint host="*" httpPort="19080" httpsPort="19443" id="defaultHttpEndpoint"/>

<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>

<!-- DataSource Conig(Db2)  -->
<library id="DB2JCC4Lib">
  <fileset dir="${shared.resource.dir}/db2" includes="db2jcc4.jar"/>
</library>

<!-- Declare the runtime database -->
<dataSource id="Db2-DS1" jndiName="jdbc/sample">
<jdbcDriver libraryRef="DB2JCC4Lib"/>
<properties.db2.jcc databaseName="hadrdb" driverType="4" portNumber="25010" serverName="host1" user="db2inst1" password="xxxxxxx" clientRerouteAlternateServerName="host2" clientRerouteAlternatePortNumber="25010" traceLevel="-1" traceFile="/work/logs/jdbctrc/trc.log"/>
</dataSource>

<!-- Declare the application -->
<application id="JDBCSample" location="JDBCSampleEAR.ear" name="JDBCSample" type="ear"/>
```

#### SSL(TLS)構成要否

ずぼら人間としては本当はSSLも無しで取得したかったですが、SSL構成を省くと403エラーとなったためあきらめてSSL有り構成としました。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/468682/8610f8a1-e98e-6642-ae50-1e03a48ec7b1.png)
> Error 403: Resource must be accessed with a secure connection try again using an HTTPS connection.

non-sslでのリクエスト時、messages.logに以下のようなエラーが出ていました。
```text:
[10/3/23 18:50:13:677 JST] 0000002d m.ibm.ws.webcontainer.security.internal.HTTPSRedirectHandler E CWWKS9113E: The SSL port is not active. The incoming http request cannot be redirected to a secure port. Check the server.xml file for configuration errors. The https port may be disabled. The keyStore element may be missing or incorrectly specified. The SSL feature may not be enabled.