Enabling JMX counters for performance monitoring

Bitbucket Data Center と Server の管理

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

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最新のアラートのタイムスタンプ
TotalCountJMX の起動以降のアラートの合計数
ErrorCountJMX の起動以降の重大度 ERROR のアラートの数
InfoCountJMX の起動以降の重大度 INFO のアラートの数
WarningCountJMX の起動以降の重大度 WARNING のアラートの数

プラグイン (com.atlassian.diagnostics:type=Alerts,Category=Plugin,name=${PLUGIN_NAME})

名前説明
LatestAlertTimestamp最新のアラートのタイムスタンプ
TotalCountJMX の起動以降のアラートの合計数
ErrorCountJMX の起動以降の重大度 ERROR のアラートの数
InfoCountJMX の起動以降の重大度 INFO のアラートの数
WarningCountJMX の起動以降の重大度 WARNING のアラートの数
PluginNameプラグイン名 (利用可能な場合)

課題 (com.atlassian.diagnostics:type=Alerts,Category=Issue,name=${ISSUE_ID})

名前説明
LatestAlertTimestamp最新のアラートのタイムスタンプ
コンポーネント課題が定義されているコンポーネント
countJMX の起動以降のその課題のアラートの数
深刻度課題の重大度
説明課題の説明


ホスティング統計情報

プロトコルオブジェクト名
sshcom.atlassian.bitbucket:name=SshHostingStatistics
httpcom.atlassian.bitbucket:name=HttpHostingStatistics

ホスティング統計属性

すべてのホスティング統計属性は、JVM の再起動以降、単調に増加します。

名前説明
CloneCacheBypassClone requests that have bypassed the scm-cache
CloneCacheHitClone requests served from the scm-cache
CloneCacheMissClone requests that could not be served from the scm-cache
CloneReadBytes read from clients during clone operations
CloneRequestCountNumber of clone requests served
CloneWritten<i>クローン<i> 操作中にクライアントに書き込まれたバイト数
FetchReadBytes read from clients during <i>fetch</i> operations
FetchRequestCountNumber of fetch requests served
FetchWrittenBytes written to clients during fetch operations
RequestsTotal number of requests served
TotalBytesReadTotal bytes read from clients
TotalBytesWrittenTotal bytes written to clients


Webhook 統計情報 (com.atlassian.webhooks:name=Webhooks)

名前説明
PublishCountwebhook をトリガーできたイベントの合計数
(公開によって多数のディスパッチが作成される場合があります)
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
IoPumpThreadPoolThreads that handle blocking process I/Ocom.atlassian.bitbucket.thread-pools:name=IoPumpThreadPool
NioPumpThreadPoolThreads that handle nonblocking process I/Ocom.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)

名前説明
countNumber 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 セッションの合計数
SessionExceptionCountSSH コマンド実行で例外がスローされたために終了した SSH セッションの合計数

Rate limiting statistics (com.atlassian.bitbucket:name=RateLimitStatistics)

名前説明
RejectedRequestCountThe number of rate limited requests
UserMapSizeThe 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:

  1. Locate and open the bitbucket.properties file in the <Bitbucket home directory>/shared directory. 
    1. ファイルにこのプロパティを追加します。

      jmx.enabled=true
    2. ファイルを保存して閉じます。
       
  2. JMX モニタリングに安全にアクセスするために、JMX パスワード ファイルを作成します。
     
  3. 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 モニタリングに安全にアクセスする方法

  1. 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.

  2. 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 or controlRole you will need to modify the jmxremote.access file located in the /lib/management/ directory of the installed Java.

  3. Change ownership of jmx.access file,

    chown bitbucket:bitbucket <path>/jmx.access

    where bitbucket is the user that runs Bitbucket service.

  4. 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:

  1. Within the bin directory, locate the file set-jmx-opts.sh (for Windows set-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
  2. 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

  1. Stop the Bitbucket service.
  2. コマンド ライン プロンプトを開いて以下を入力します。

    cmd
  3. Navigate to the Bitbucket bin directory.

    cd <Bitbucket installation dir>\bin
  4. 次のコマンドを実行します。

    tomcat8w //ES//AtlassianBitbucket Server
  5. 表示されたウィンドウで [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.

  6. <> 文字内の値を置き換えます。

    JMX_REMOTE_PORT=3333
    JMX_PASSWORD_FILE=<path>\jmx.access
  7. Restart the Bitbucket service.


JMX が正しく構成されていることを確認する

これらの手順では、JMX が正しく設定されていることをテストするのに JConsole を使用します。JConsole は、Oracle JDK に同梱されているユーティリティです。

  1. jconsole ユーティリティを起動するには、コマンド ライン プロンプトから以下を入力します。

    jconsole

  2. 同様の接続設定で新しい JConsole 接続を作成します。

    bitbucketthe hostname of the instance to monitor

    3333

    以前に構成した JMX ポート番号。

    username, passwordvalues configured within the JMX password file jmx.access.
  3. 接続 をクリックします。


正しく設定されている場合、これらのプロパティが表示されます。

com.atlassian.bitbucket
  • CommandTickets
  • HostingTickets
  • プロジェクト
  • リポジトリ
  • ScmStatistics
  • Tickets
  • EventStatistics
  • ClusterLocks

  • SshSessions

com.atlassian.bitbucket.thread-pools
  • EventThreadPool
  • IoPumpThreadPool
  • ScheduledThreadPool

パフォーマンス ダッシュボードの例

このダッシュボードは、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.


Last modified on Mar 2, 2022

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.