1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AzureAppService for Containers でApplicationInsight(Monitor)にSpringBootのメトリクスを送信する

Posted at

はじめに

コンテナーに対する Azure Monitor の概要」に書かれている対象サービスは以下の通りでAppService for Containerは含まれていないのです

  • Azure Kubernetes Service (AKS) にホストされているマネージド Kubernetes クラスター
  • Azure Container Instances
  • Azure Stack またはオンプレミスでホストされた自己管理の Kubernetes クラスター
  • Azure Red Hat OpenShift

確かにAzurePortal上でもグレーアウトされておりみることができないようでした。

image.png

SpringのActuatorに対してAzureFunctionsで定期的にリクエストを投げて、AzureMonitorにカスタムメトリクスを投げないといけないのかな・・・・・と暗い気持ちになっていたところ・・・送る仕組みがありましたのでご紹介です。

設定の仕方

azure-spring-boot-metrics-starter」を使います。

まずはモニター→アプリケーションから追加を押してメトリクスを入れる箱を作ります。

image.png

インストルメンテーション キーをコピーしておきます。

image.png

SpringBootのアプリケーションのGradleの設定をしていきます。

build.gradle
compile group: 'com.microsoft.azure', name: 'azure-spring-boot-metrics-starter', version: '2.2.2'

application.propertiesに先ほどコピーしたインストルメンテーション キーを設定します。

application.properties
server.port=80
management.metrics.export.azuremonitor.instrumentation-key=INSTRUMENTATION-KEY

これで準備は完了です。コンテナをpushして再デプロイしましょう

結果

ちゃんとグラフ化できました。もちろんアラートルールの設定もできますね。

image.png

ソースを見ればわかりますが内部ではPivotalのMicrometerを使っているのでMicrometerのマニュアルを見れば何が取れるのかがわかります。

JVM関連であればJVM and System Metricsをみればよさそうですね。

メトリクスのON/OFF

いらないなーっていうメトリクスがある場合、送信しないように設定することもできます。

JVM メトリック:
management.metrics.binders.jvm.enabled=false
Logback メトリック:
management.metrics.binders.logback.enabled=false
アップタイム メトリック:
management.metrics.binders.uptime.enabled=false
プロセッサ メトリック:
management.metrics.binders.processor.enabled=false
FileDescriptorMetrics:
management.metrics.binders.files.enabled=false
Hystrix メトリック (クラスパス上にライブラリがある場合):
management.metrics.binders.hystrix.enabled=false
AspectJ メトリック (クラスパス上にライブラリがある場合):
spring.aop.enabled=false
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?