Enabling JMX counters for performance monitoring
This article describes how to expose JMX MBeans within Bitbucket Data Center and Server for monitoring with a JMX client.
JMX とは何か
JMX (Java Management eXtensions) は、Java アプリケーションの監視と管理を行うためのテクノロジーです。JMX は MBean (Managed Bean) と呼ばれるオブジェクトを使用してアプリケーションのデータとリソースを公開します。
Why would I want to enable JMX monitoring within Bitbucket?
On this page:
関連ページ:
For large Bitbucket instances, enabling JMX allows you to more easily monitor the consumption of application resources. This enables you to make better decisions about how to maintain and optimize machine resources.
JMX を使用して何を監視できますか?
It is possible to monitor various statistics using JMX counters within Bitbucket. Below are some examples of some statistics that can be monitored.
メール統計情報 (com.atlassian.bitbucket:name=MailStatistics)
名前 | 説明 |
---|---|
AverageMessageSize | 送信されたメッセージの平均サイズ (バイト単位) |
LargestMessageSent | 送信された最大メッセージ (バイト単位) |
LastMessageFailure | メッセージの送信に最後に失敗した日付 |
LastMessageSuccess | メッセージの送信操作に最後に成功した日付 |
LastQueueFullEvent | メッセージ キューが前回満杯になった時間 |
QueueFullEventCount | メッセージ キューが満杯になった回数 |
QueueUsage | キューの使用率を小数で表したもの。0.0d は空を、1.0d は満杯の状態を示します |
QueuedMessagesCount | キューにある (未送信の) メッセージの現在の数 |
QueuedMessagesSize | キューにある (未送信の) メッセージの現在のサイズ (バイト単位) |
TotalMailDataSent | 送信されたメッセージの合計サイズ (バイト単位) |
TotalMessagesFailed | 送信に失敗したメッセージの合計数 |
TotalMessagesSent | 送信済みのメッセージの合計数 |
診断
アラート合計 (com.atlassian.diagnostics:type=Alerts,name=Total)
名前 | 説明 |
---|---|
LatestAlertTimestamp | 最新のアラートのタイムスタンプ |
TotalCount | JMX の起動以降のアラートの合計数 |
ErrorCount | JMX の起動以降の重大度 ERROR のアラートの数 |
InfoCount | JMX の起動以降の重大度 INFO のアラートの数 |
WarningCount | JMX の起動以降の重大度 WARNING のアラートの数 |
プラグイン (com.atlassian.diagnostics:type=Alerts,Category=Plugin,name=${PLUGIN_NAME})
名前 | 説明 |
---|---|
LatestAlertTimestamp | 最新のアラートのタイムスタンプ |
TotalCount | JMX の起動以降のアラートの合計数 |
ErrorCount | JMX の起動以降の重大度 ERROR のアラートの数 |
InfoCount | JMX の起動以降の重大度 INFO のアラートの数 |
WarningCount | JMX の起動以降の重大度 WARNING のアラートの数 |
PluginName | プラグイン名 (利用可能な場合) |
課題 (com.atlassian.diagnostics:type=Alerts,Category=Issue,name=${ISSUE_ID})
名前 | 説明 |
---|---|
LatestAlertTimestamp | 最新のアラートのタイムスタンプ |
コンポーネント | 課題が定義されているコンポーネント |
count | JMX の起動以降のその課題のアラートの数 |
深刻度 | 課題の重大度 |
説明 | 課題の説明 |
ホスティング統計情報
プロトコル | オブジェクト名 |
---|---|
ssh | com.atlassian.bitbucket:name=SshHostingStatistics |
http | com.atlassian.bitbucket:name=HttpHostingStatistics |
ホスティング統計属性
すべてのホスティング統計属性は、JVM の再起動以降、単調に増加します。
名前 | 説明 |
---|---|
CloneCacheBypass | Clone requests that have bypassed the scm-cache |
CloneCacheHit | Clone requests served from the scm-cache |
CloneCacheMiss | Clone requests that could not be served from the scm-cache |
CloneRead | Bytes read from clients during clone operations |
CloneRequestCount | Number of clone requests served |
CloneWritten | <i>クローン<i> 操作中にクライアントに書き込まれたバイト数 |
FetchRead | Bytes read from clients during <i>fetch</i> operations |
FetchRequestCount | Number of fetch requests served |
FetchWritten | Bytes written to clients during fetch operations |
Requests | Total number of requests served |
TotalBytesRead | Total bytes read from clients |
TotalBytesWritten | Total bytes written to clients |
Webhook 統計情報 (com.atlassian.webhooks:name=Webhooks)
名前 | 説明 |
---|---|
PublishCount | webhook をトリガーできたイベントの合計数 (公開によって多数のディスパッチが作成される場合があります) |
DispatchSuccessCount | 正常な HTTP レスポンスによって正常に起動した webhook の合計数 |
DispatchRejectedCount | 実行が拒否された webhook ディスパッチの数 |
DispatchLastRejectedTimestamp | サーキット ブレークによって、または多数の webhook が動作したために前回 webhook が拒否された時刻 |
DispatchInFlightCount | トリガーされたディスパッチと解決を待機しているディスパッチの合計数 |
DispatchFailureCount | 正常に起動したが HTTP レスポンスが失敗を示している webhook の合計数 (非 2xx コード) |
DispatchErrorCount | ディスパッチされたときにエラーが発生した webhook の合計数 |
DispatchCount | ディスパッチされた webhook の合計数 |
スレッド プール
スレッド プール | 説明 | オブジェクト名 |
---|---|---|
BuildActionsThreadPool | Threads that handle Integrated CI/CD build actions | com.atlassian.bitbucket.thread-pools:name=BuildActionsThreadPool |
EventThreadPool | イベントを @EventListenermethods にディスパッチするスレッド | com.atlassian.bitbucket.thread-pools:name=EventThreadPool |
IoPumpThreadPool | Threads that handle blocking process I/O | com.atlassian.bitbucket.thread-pools:name=IoPumpThreadPool |
NioPumpThreadPool | Threads that handle nonblocking process I/O | com.atlassian.bitbucket.thread-pools:name=NioPumpThreadPool |
ScheduledThreadPool | さまざまな複数のスケジュール済みタスクを処理するスレッド プール | com.atlassian.bitbucket.thread-pools:name=ScheduledThreadPool |
スレッド プール属性
名前 | 説明 |
---|---|
ActiveCount | アクティブにタスクを実行しているスレッド数の概算を返します。 |
MaximumPoolSize | 最大許容スレッド数を返します。 |
PoolSize | 現在プール内にあるスレッド数を返します。 |
QueueLength | スレッド プールによる実行待ちのタスクの数 |
LargestPoolSize | プール内に同時に存在したスレッドの最大数 |
CompletedTaskCount | 実行が完了したタスクの合計数の概算。タスクおよびスレッドの状態は計算中に動的に変わる場合があるため、返される値はおおよその値ですが、この値が成功呼び出し全体で減ることはありません。 |
リポジトリ (com.atlassian.bitbucket:name=Repositories)
名前 | 説明 |
---|---|
count | Number of repositories currently configured across all projects |
Scm 統計 (com.atlassian.bitbucket:name=ScmStatistics)
名前 | 説明 |
---|---|
Pulls | 開始以降、このインスタンスが提供した scm プルの数 |
Pushes | インスタンスの開始以降、このインスタンスが受信した scm プッシュの数 |
チケット統計
Bitbucket uses 'tickets' as a mechanism for creating back-pressure to prevent the system from being overloaded with requests. There are two types of tickets, hosting tickets and command tickets.
Hosting tickets (com.atlassian.bitbucket:name=HostingTickets): Limits the number of SCM hosting operations, meaning pushes and pulls over HTTP or SSH, which may be running concurrently.
Command tickets(com.atlassian.bitbucket:name=CommandTickets): Limits the number of SCM commands, such as: `git diff`, `git blame`, or `git rev-list`, which may be running concurrently.
Bitbucket supports the following metrics for each ticket type.
名前 | 説明 |
---|---|
Available | 取得に利用できるチケットの数 (数値が小さいほど負荷が大きくなります) |
LastRejection | 前回拒否されたチケットのタイムスタンプ、チケットが拒否されていない場合は null |
名前 | チケット バケットの名前 ("scm-command" または "scm-hosting") |
OldestQueuedRequest | キューに最初に追加されたリクエストが開始を待機した時間のタイムスタンプ、キューにリクエストがない場合は null |
QueuedRequests | 利用可能なチケットを現在待機しているリクエストの数 |
合計 | バックプレッシャーが適用されるまでに同時に取得できるチケットの最大数 |
Used | 取得されたチケットの数 (数値が大きいほど負荷が大きくなります) |
イベント統計 (com.atlassian.bitbucket:name=EventStatistics)
名前 | 説明 |
---|---|
DispatchedCount | 実行されたリスナー コールバックの合計数。10 リスナーに配信されるイベントが 10 ディスパッチとカウントされます |
LastRejection | 前回のイベントが拒否された日付、イベントが拒否されていない場合は null |
PublishedCount | 配信されたイベントの総数。10 リスナーに配信されるイベントが 1 イベントとカウントされます。 |
QueueCapacity | イベントが却下される前にキューに追加できるイベント コールバックの最大数 |
QueueLength | キューに追加されているがまだディスパッチされていないイベント コールバックの数 |
RejectedCount | イベント キューが満杯だったためにディスパッチされなかったイベントの合計数 |
RemainingQueueCapacity | イベントが却下される前にキューに追加できるイベント コールバックの残りの数 |
クラスタ ロック統計情報 (com.atlassian.bitbucket:name=ClusterLocks)
名前 | 説明 |
---|---|
LockedCount | このノードが現在保持しているクラスタ ロックの数 |
QueuedThreadCount | このノード上の、現在ロックを待機してブロックされているスレッド数 |
TotalAcquiredCount | このノードの起動以降、ノードでクラスタ ロックが取得された合計回数 |
TotalAcquireErrorCount | このノードの起動以降、ノードでクラスタ ロックを取得しようとしているときに例外がスローされた回数 |
TotalAcquireTimeMillis | このノードで任意のスレッドがロックの取得に費やしたミリ秒単位の合計時間 (ロックが使用可能になるまで待機しているブロック時間を含む) |
TotalReleasedCount | このノードの起動以降、ノードでクラスタ ロックが解放された合計回数 |
TotalReleaseErrorCount | このノードの起動以降、ノードでクラスタ ロックの開放中に例外がスローされた合計回数 |
SSH セッション統計 (com.atlassian.bitbucket:name=SshSessions)
名前 | 説明 |
---|---|
ActiveSessionCount | 現在アクティブな SSH セッションの数 |
MaxActiveSessionCount | 前回の起動以降、同時にアクティブな SSH セッションの最大数 |
SessionClosedCount | 前回の起動以降、クローズされた SSH セッションの合計数 |
SessionCreatedCount | 前回の起動以降、作成された SSH セッションの合計数 |
SessionExceptionCount | SSH コマンド実行で例外がスローされたために終了した SSH セッションの合計数 |
Rate limiting statistics (com.atlassian.bitbucket:name=RateLimitStatistics)
名前 | 説明 |
---|---|
RejectedRequestCount | The number of rate limited requests |
UserMapSize | The number of token buckets currently in memory |
サードパーティ ライブラリ属性
Bitbucket exposes the JMX attributes from number of third party libraries. Listed below is a sample of the attributes that are particularly interesting from an operations perspective.
HikariCP - (com.zaxxer.hikari:type=Pool (bitbucket))
名前 | 説明 |
---|---|
ActiveConnections | アクティブ接続数 (使用中) |
IdleConnections | アイドル接続数 |
ThreadsAwaitingConnection | 接続を待機しているスレッドの数 (利用可能なすべての接続が使用中の場合) |
TotalConnections | 合計接続数 |
Hibernate - (org.hibernate.core:sessionFactory=bitbucket.core,serviceRole=org.hibernate.stat.Statistics,serviceType=org.hibernate.stat.internal.ConcurrentStatisticsImpl)
名前 | 説明 |
QueryCacheHitCount | キャッシュから正常に取得されたキャッシュ済みクエリのグローバル数 |
QueryCacheMissCount | キャッシュ内で検出されなかったキャッシュ済みクエリのグローバル数 |
SecondLevelCacheHitCount | キャッシュから正常に取得されたキャッシュ可能エンティティ / コレクションのグローバル数 |
SecondLevelCacheMissCount | キャッシュ内で検出されず、データベースからロードされたキャッシュ可能エンティティ / コレクションのグローバル数 |
Expose JMX MBeans within Bitbucket
To enable Bitbucket to publish specific statistics using JMX:
- Locate and open the
bitbucket.properties
file in the<Bitbucket home directory>
/shared
directory.ファイルにこのプロパティを追加します。
jmx.enabled=true
- ファイルを保存して閉じます。
- JMX モニタリングに安全にアクセスするために、JMX パスワード ファイルを作成します。
- Modify the
set-jmx-opts.sh
file to enable Bitbucket to expose JMX Mbeans.
These changes will not take effect until Bitbucket is restarted.
JMX パスワード ファイルのセットアップ
JMX パスワード ファイルをセットアップして、JMX モニタリングに安全にアクセスする方法
Create a file named
jmx.access.
This file will contain password information. Ensure the file is only readable by the secure user Bitbucket will run under. However, note that if the user cannot read the file Bitbucket will fail to start.
Edit the
jmx.access
file to include this property and save the file.monitorRole <password>
If you wish to use a username other than
monitorRole
orcontrolRole
you will need to modify the jmxremote.access file located in the /lib/management/
directory of the installed Java.Change ownership of
jmx.access
file,chown bitbucket:bitbucket <path>/jmx.access
where
bitbucket
is the user that runs Bitbucket service.Change file permissions of
jmx.access
file.chmod 600 <path>/jmx.access
Modify the Bitbucket environment file
Modify the set-jmx-opts.sh
(for Windows set-jmx-opts.bat
) files to enable JMX monitoring:
Within the
bin
directory, locate the fileset-jmx-opts.sh
(for Windowsset-jmx-opts.bat
) and change these properties.JMX_REMOTE_AUTH=password JMX_REMOTE_PORT=3333 RMI_SERVER_HOSTNAME=-Djava.rmi.server.hostname=<hostname> JMX_PASSWORD_FILE=<path>/jmx.access
- Bitbucket を再起動します。
Docker
For Docker deployments, the properties can be passed as Docker environment variables:
Sample:
docker run -v /data/bitbucket:/var/atlassian/application-data/bitbucket \
--name="bitbucket" \
-d -p 7990:7990 -p 7999:7999 -p 3333:3333 \
-e JMX_ENABLED=true \
-e JMX_REMOTE_AUTH=password \
-e JMX_REMOTE_PORT=3333 \
-e JMX_REMOTE_RMI_PORT=3333 \
-e RMI_SERVER_HOSTNAME=<hostname> \
-e JMX_PASSWORD_FILE=<path>/jmx.access \
atlassian/bitbucket
Expose JMX MBeans when Bitbucket is run as a Windows service
To expose JMX MBeans when Bitbucket is run as a Windows service
- Stop the Bitbucket service.
コマンド ライン プロンプトを開いて以下を入力します。
cmd
Navigate to the Bitbucket
bin
directory.cd <Bitbucket installation dir>\bin
次のコマンドを実行します。
tomcat8w //ES//AtlassianBitbucket Server
表示されたウィンドウで [Java] タブをクリックすると、現在の起動オプションの一覧が表示されます。[Java Options:] フォームで、値を入力します。
-Dcom.sun.management.jmxremote.port=<JMX_REMOTE_PORT> -Djava.rmi.server.hostname=<hostname> -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=<JMX_PASSWORD_FILE>
Ensure the owner of this password file is the secure user Bitbucket will run as. If the user cannot read the file, Bitbucket will fail to start.
<> 文字内の値を置き換えます。
JMX_REMOTE_PORT=3333 JMX_PASSWORD_FILE=<path>\jmx.access
Restart the Bitbucket service.
JMX が正しく構成されていることを確認する
これらの手順では、JMX が正しく設定されていることをテストするのに JConsole を使用します。JConsole は、Oracle JDK に同梱されているユーティリティです。
jconsole ユーティリティを起動するには、コマンド ライン プロンプトから以下を入力します。
jconsole
同様の接続設定で新しい JConsole 接続を作成します。
bitbucket the hostname of the instance to monitor 3333
以前に構成した JMX ポート番号。
username, password values configured within the JMX password file jmx.access
.接続 をクリックします。
正しく設定されている場合、これらのプロパティが表示されます。
com.atlassian.bitbucket |
|
com.atlassian.bitbucket.thread-pools |
|
パフォーマンス ダッシュボードの例
このダッシュボードは、Oracle JDK (1.7u40 以降) に同梱されている Java Mission Control を使用して生成されました。詳細については、ご利用の JMX クライアントに同梱しているドキュメントを参照してください。
SSL を使用するように JMX を設定する
You can find information about the options for configuring JMX to use SSL in the set-jmx-opts
files. Comprehensive documentation is available from Oracle.