collectd java_监视 Linux 上 Java Web 应用的性能 - Azure - Azure Monitor | Microsoft Docs

您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

collectd:Application Insights 中的 Linux 性能指标 [已弃用]collectd: Linux performance metrics in Application Insights [Deprecated]

03/14/2019

本文内容

重要

若要监视 Java 应用程序,建议的方法是在不更改代码的情况下使用自动检测。The recommended approach to monitor Java applications is to use the auto-instrumentation without changing the code.

若要浏览 Application Insights 中 Linux 系统性能指标,请安装 collectd 及其 Application Insights 插件。To explore Linux system performance metrics in Application Insights, install collectd, together with its Application Insights plug-in. 此开放源解决方案收集了各种系统和网络统计信息。This open-source solution gathers various system and network statistics.

它可提供更多数据,有助于增强应用性能或诊断问题。It gives you more data to help you to enhance your app's performance or diagnose problems.

获取检测密钥Get your instrumentation key

复制可标识资源的检测密钥。Take a copy of the instrumentation key, which identifies the resource.

a3c173694f06671f8424618c7576cd7b.png

安装 collectd 和插件Install collectd and the plug-in

在 Linux 服务器计算机上:On your Linux server machines:

安装 collectd 版本 5.4.0 或更高版本。Install collectd version 5.4.0 or later.

将插件 JAR 复制到 /usr/share/collectd/java。Copy the plugin JAR into /usr/share/collectd/java.

编辑 /etc/collectd/collectd.conf:Edit /etc/collectd/collectd.conf:

Ensure that the Java plugin is enabled.

更新 java.class.path 的 JVMArg,以包括以下 JAR。Update the JVMArg for the java.class.path to include the following JAR. 更新版本号,以匹配下载版本:Update the version number to match the one you downloaded:

/usr/share/collectd/java/applicationinsights-collectd-1.0.5.jar

使用资源中的检测密钥添加此代码段:Add this snippet, using the Instrumentation Key from your resource:

LoadPlugin "com.microsoft.applicationinsights.collectd.ApplicationInsightsWriter"

InstrumentationKey "Your key"

以下是示例配置文件的一部分:Here's part of a sample configuration file:

...

# collectd plugins

LoadPlugin cpu

LoadPlugin disk

LoadPlugin load

...

# Enable Java Plugin

LoadPlugin "java"

# Configure Java Plugin

JVMArg "-verbose:jni"

JVMArg "-Djava.class.path=/usr/share/collectd/java/applicationinsights-collectd-1.0.5.jar:/usr/share/collectd/java/collectd-api.jar"

# Enabling Application Insights plugin

LoadPlugin "com.microsoft.applicationinsights.collectd.ApplicationInsightsWriter"

# Configuring Application Insights plugin

InstrumentationKey "12345678-1234-1234-1234-123456781234"

# Other plugin configurations ...

...

...

配置其他 collectd 插件,其可从不同源中收集各种数据。Configure other collectd plugins, which can collect various data from different sources.

根据其手册重启 collectd。Restart collectd according to its manual.

查看 Application Insights 中的数据View the data in Application Insights

在 Application Insights 资源中,打开指标和添加图表,选择要从“自定义”类别查看的指标。In your Application Insights resource, open Metrics and add charts, selecting the metrics you want to see from the Custom category.

默认情况下,会从收集指标的所有主机中聚合指标。By default, the metrics are aggregated across all host machines from which the metrics were collected. 要查看每个主机的指标,在“图表”详细信息边栏选项卡中,打开“分组”,并选择按 CollectD-Host 分组。To view the metrics per host, in the Chart details blade, turn on Grouping and then choose to group by CollectD-Host.

排除特定统计信息的上传To exclude upload of specific statistics

默认情况下,Application Insights 插件会发送由启用的所有 collectd“读取”插件收集的所有数据。By default, the Application Insights plugin sends all the data collected by all the enabled collectd 'read' plugins.

排除特定插件或数据源中的数据:To exclude data from specific plugins or data sources:

编辑配置文件。Edit the configuration file.

在 中,添加如下指令行:In , add directive lines like this:

指令Directive

效果Effect

Exclude disk

排除由 disk 插件收集的所有数据Exclude all data collected by the disk plugin

Exclude disk:read,write

排除 disk 插件中名为 read 和 write 的源。Exclude the sources named read and write from the disk plugin.

使用新行分隔指令。Separate directives with a newline.

遇到问题?Problems?

在门户中看不到数据I don't see data in the portal

打开搜索,查看原始事件是否已到达。Open Search to see if the raw events have arrived. 有时需较长时间才能在指标资源管理器中看到数据。Sometimes they take longer to appear in metrics explorer.

在 Application Insights 插件中启用跟踪。Enable tracing in the Application Insights plugin. 在 中添加此行:Add this line within :

SDKLogger true

打开终端并在详细模式下启动 collectd,查看其报告的任何问题:Open a terminal and start collectd in verbose mode, to see any issues it is reporting:

sudo collectd -f

已知问题Known issue

Application Insights 写入插件与某些读取插件不兼容。The Application Insights Write plugin is incompatible with certain Read plugins. Application Insights 插件需要浮点数时,有些插件有时会发送“NaN”。Some plugins sometimes send "NaN" where the Application Insights plugin expects a floating-point number.

症状:collectd 日志显示包括“AI: ...SyntaxError:意外的令牌 N”的错误。Symptom: The collectd log shows errors that include "AI: ... SyntaxError: Unexpected token N".

解决方法:排除由问题写入插件收集的数据。Workaround: Exclude data collected by the problem Write plugins.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值