Windows 性能计数器输入插件
此插件从收集的 Windows 性能计数器生成指标。
引入于: Telegraf v0.10.2 标签: system 操作系统支持: windows
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Input plugin to counterPath Performance Counters on Windows operating systems
# This plugin ONLY supports Windows
[[inputs.win_perf_counters]]
## By default this plugin returns basic CPU and Disk statistics. See the
## README file for more examples. Uncomment examples below or write your own
## as you see fit. If the system being polled for data does not have the
## Object at startup of the Telegraf agent, it will not be gathered.
## Print All matching performance counters
# PrintValid = false
## Whether request a timestamp along with the PerfCounter data or use current
## time
# UsePerfCounterTime = true
## If UseWildcardsExpansion params is set to true, wildcards (partial
## wildcards in instance names and wildcards in counters names) in configured
## counter paths will be expanded and in case of localized Windows, counter
## paths will be also localized. It also returns instance indexes in instance
## names. If false, wildcards (not partial) in instance names will still be
## expanded, but instance indexes will not be returned in instance names.
# UseWildcardsExpansion = false
## When running on a localized version of Windows and with
## UseWildcardsExpansion = true, Windows will localize object and counter
## names. When LocalizeWildcardsExpansion = false, use the names in
## object.Counters instead of the localized names. Only Instances can have
## wildcards in this case. ObjectName and Counters must not have wildcards
## when this setting is false.
# LocalizeWildcardsExpansion = true
## Period after which counters will be reread from configuration and
## wildcards in counter paths expanded
# CountersRefreshInterval="1m"
## Accepts a list of PDH error codes which are defined in pdh.go, if this
## error is encountered it will be ignored. For example, you can provide
## "PDH_NO_DATA" to ignore performance counters with no instances. By default
## no errors are ignored You can find the list here:
## https://github.com/influxdata/telegraf/blob/master/plugins/inputs/win_perf_counters/pdh.go
## e.g. IgnoredErrors = ["PDH_NO_DATA"]
# IgnoredErrors = []
## Maximum size of the buffer for values returned by the API
## Increase this value if you experience "buffer limit reached" errors.
# MaxBufferSize = "4MiB"
## NOTE: Due to the way TOML is parsed, tables must be at the END of the
## plugin definition, otherwise additional config options are read as part of
## the table
# [[inputs.win_perf_counters.object]]
# Measurement = ""
# ObjectName = ""
# Instances = [""]
# Counters = []
## Additional Object Settings
## * IncludeTotal: set to true to include _Total instance when querying
## for all metrics via '*'
## * WarnOnMissing: print out when the performance counter is missing
## from object, counter or instance
## * UseRawValues: gather raw values instead of formatted. Raw values are
## stored in the field name with the "_Raw" suffix, e.g.
## "Disk_Read_Bytes_sec_Raw".
# IncludeTotal = false
# WarnOnMissing = false
# UseRawValues = false
## Processor usage, alternative to native, reports on a per core.
# [[inputs.win_perf_counters.object]]
# Measurement = "win_cpu"
# ObjectName = "Processor"
# Instances = ["*"]
# UseRawValues = true
# Counters = [
# "% Idle Time",
# "% Interrupt Time",
# "% Privileged Time",
# "% User Time",
# "% Processor Time",
# "% DPC Time",
# ]
## Disk times and queues
# [[inputs.win_perf_counters.object]]
# Measurement = "win_disk"
# ObjectName = "LogicalDisk"
# Instances = ["*"]
# Counters = [
# "% Idle Time",
# "% Disk Time",
# "% Disk Read Time",
# "% Disk Write Time",
# "% User Time",
# "% Free Space",
# "Current Disk Queue Length",
# "Free Megabytes",
# ]
# [[inputs.win_perf_counters.object]]
# Measurement = "win_diskio"
# ObjectName = "PhysicalDisk"
# Instances = ["*"]
# Counters = [
# "Disk Read Bytes/sec",
# "Disk Write Bytes/sec",
# "Current Disk Queue Length",
# "Disk Reads/sec",
# "Disk Writes/sec",
# "% Disk Time",
# "% Disk Read Time",
# "% Disk Write Time",
# ]
# [[inputs.win_perf_counters.object]]
# Measurement = "win_net"
# ObjectName = "Network Interface"
# Instances = ["*"]
# Counters = [
# "Bytes Received/sec",
# "Bytes Sent/sec",
# "Packets Received/sec",
# "Packets Sent/sec",
# "Packets Received Discarded",
# "Packets Outbound Discarded",
# "Packets Received Errors",
# "Packets Outbound Errors",
# ]
# [[inputs.win_perf_counters.object]]
# Measurement = "win_system"
# ObjectName = "System"
# Instances = ["------"]
# Counters = [
# "Context Switches/sec",
# "System Calls/sec",
# "Processor Queue Length",
# "System Up Time",
# ]
## Example counterPath where the Instance portion must be removed to get
## data back, such as from the Memory object.
# [[inputs.win_perf_counters.object]]
# Measurement = "win_mem"
# ObjectName = "Memory"
## Use 6 x - to remove the Instance bit from the counterPath.
# Instances = ["------"]
# Counters = [
# "Available Bytes",
# "Cache Faults/sec",
# "Demand Zero Faults/sec",
# "Page Faults/sec",
# "Pages/sec",
# "Transition Faults/sec",
# "Pool Nonpaged Bytes",
# "Pool Paged Bytes",
# "Standby Cache Reserve Bytes",
# "Standby Cache Normal Priority Bytes",
# "Standby Cache Core Bytes",
# ]
## Example query where the Instance portion must be removed to get data back,
## such as from the Paging File object.
# [[inputs.win_perf_counters.object]]
# Measurement = "win_swap"
# ObjectName = "Paging File"
# Instances = ["_Total"]
# Counters = [
# "% Usage",
# ]基础知识
本文件中包含的示例是在互联网上找到的,用于在性能监控 Active Directory 和 IIS 时使用的计数器。如果您知道要监控的内容,还有许多其他有用的对象。此文件将来可能会根据特定场景的有用配置进行更新,并添加更多示例。
有关对象、计数器和实例名称等概念和术语的更多信息,请参阅 Windows 性能监视器应用程序中的帮助。
架构
测量名称根据性能对象或默认的 win_perf_counters 指定。
标签
- source - 计算机名称,如
Sources参数中所指定。名称localhost被翻译为主机名 - objectname - 性能对象的规范化名称
- instance - 实例名称,如果性能对象支持多个实例,则保留,否则省略
字段是性能对象的计数器。字段名称是规范化的计数器名称。
插件范围
插件范围的条目位于 [[inputs.win_perf_counters]] 下。
PrintValid
布尔值,如果设置为 true,将打印出所有匹配的性能对象。
示例: PrintValid=true
UseWildcardsExpansion
如果 UseWildcardsExpansion 为 true,则可以在实例名称和计数器名称中使用通配符。实例索引也将作为实例名称返回。
部分通配符(例如 chrome*)仅在 Windows Vista 及更高版本中支持实例名称。
如果禁用,仍然可以在实例名称中使用通配符(非部分通配符),但实例索引不会作为实例名称返回。
示例: UseWildcardsExpansion=true
LocalizeWildcardsExpansion
LocalizeWildcardsExpansion 用于选择当 UseWildcardsExpansion 为 true 且 Telegraf 在本地化安装的 Windows 上运行时,对象和计数器名称是否本地化。
当 LocalizeWildcardsExpansion 为 true 时,即使对象和计数器名称为英文,Telegraf 也会生成具有本地化标签和字段的指标。
当 LocalizeWildcardsExpansion 为 false 时,Telegraf 期望对象和计数器名称为英文,并生成具有英文标签和字段的指标。
当 LocalizeWildcardsExpansion 为 false 时,通配符只能用于实例。对象和计数器名称不得包含通配符。
示例: LocalizeWildcardsExpansion=true
CountersRefreshInterval
配置的计数器将在 CountersRefreshInterval 参数指定的间隔内与可用计数器进行匹配。默认值为 1m (1 分钟)。
如果在实例或计数器名称中使用通配符,并且 UseWildcardsExpansion 参数设置为 true,则它们将在此时展开。
将 CountersRefreshInterval 设置得过低(以秒为单位)可能会导致 Telegraf 产生高 CPU 负载。
将其设置为 0s 可禁用定期刷新。
示例: CountersRefreshInterval=1m
UsePerfCounterTime
布尔值,如果设置为 true,将请求一个时间戳以及 PerfCounter 数据。如果设置为 false,则使用当前时间。
支持 Windows Vista/Windows Server 2008 及更新版本 示例: UsePerfCounterTime=true
IgnoredErrors
IgnoredErrors 接受 pdh.go 中定义的 PDH 错误代码列表,如果遇到此错误,则会忽略它。例如,您可以提供“PDH_NO_DATA”来忽略没有实例的性能计数器,但默认情况下不忽略任何错误。您可以在此处找到可能的错误列表:PDH 错误。
示例: IgnoredErrors=["PDH_NO_DATA"]
Sources (可选)
要从中收集所有性能计数器的计算机的主机名或 IP 地址。运行 Telegraf 的用户必须已通过身份验证才能访问远程计算机(们)。例如,通过 Windows 共享 net use \\SQL-SERVER-01。使用 localhost ("localhost") 或实际的本地计算机名来收集 localhost 以及其他计算机的计数器。如果只从 localhost 收集,则跳过。
如果某个性能计数器仅在特定主机上存在,请在特定计数器级别的配置中设置 Sources 参数以覆盖全局(插件范围)的 sources。
示例: Sources = ["localhost", "SQL-SERVER-01", "SQL-SERVER-02", "SQL-SERVER-03"]
默认: Sources = ["localhost"]
Object
请参阅下面的 Entry。
Entry
新的配置条目由 TOML 头部开始,形式为 [[inputs.win_perf_counters.object]]。这必须在主 win_perf_counters 条目 [[inputs.win_perf_counters]] 下方,在其他插件配置之前。
之后是 3 个必需的键/值对以及三个可选参数及其用法。
ObjectName (必需)
ObjectName 是要查询的对象,例如 Processor、DirectoryServices、LogicalDisk 或类似对象。
示例: ObjectName = "LogicalDisk"
Instances (必需)
Instances 键(这是一个数组)声明了您希望返回的计数器的实例,可以是一个或多个值。
示例: Instances = ["C:","D:","E:"]
这将仅返回 C:、D: 和 E: 的实例(如果适用)。要获取计数器的所有实例,请仅使用 ["*"]。默认情况下,任何包含 _Total 的结果都会被剔除,除非将其指定为所需实例。或者,请参阅下面的 IncludeTotal 选项。
如果 UseWildcardsExpansion 参数设置为 true,也可以设置部分通配符,例如 ["chrome*"]。
有些对象根本没有实例可供选择。这里只有一个选项可以获取数据,那就是指定 Instances = ["------"]。
Counters (必需)
Counters 键(这是一个数组)声明了您希望返回的 ObjectName 的计数器,也可以是一个或多个值。
示例: Counters = ["% Idle Time", "% Disk Read Time", "% Disk Write Time"]
必须为每个您想要结果的计数器指定此项,或者如果 UseWildcardsExpansion 参数设置为 true,则使用 ["*"] 来获取对象的所有计数器。
Sources (Object) (可选)
覆盖当前性能对象的 Sources 全局参数。有关更多详细信息,请参阅 Sources 说明。
Measurement (可选)
此键是可选的。如果未设置,则默认为 win_perf_counters。在 InfluxDB 中,这是存储返回数据下的键。因此,为了以良好的方式组织数据,当您希望将 IIS 和磁盘结果与处理器结果分开存储时,这是一个设置具有值的良好键。
示例: Measurement = "win_disk"
UseRawValues (可选)
此键是可选的。它是一个简单的布尔值。如果设置为 true,计数器值将以原始整数形式提供。这与默认行为相反,默认行为是返回格式化、可显示的窗体,如 Windows 性能监视器中所见。
表示原始计数器值的字段具有 _Raw 后缀。原始值应进一步用于计算,例如 100-(non_negative_derivative("Percent_Processor_Time_Raw",1s)/100000 注意:基于时间的计数器(例如,% Processor Time)以百分之一纳秒为单位报告。此键是可选的。它是一个简单的布尔值。如果设置为 true,计数器值将以原始整数形式提供。这与默认行为相反,默认行为是返回格式化、可显示的窗体,如 Windows 性能监视器中所见。表示原始计数器值的字段具有 _Raw 后缀。原始值应进一步用于计算,例如 100-(non_negative_derivative("Percent_Processor_Time_Raw",1s)/100000 注意:基于时间的计数器(例如,% Processor Time)以百分之一纳秒为单位报告。
示例: UseRawValues = true
IncludeTotal (可选)
此键是可选的。它是一个简单的布尔值。如果未设置为 true 或未包含,则默认为 false。此键仅在 Instances 键设置为 ["*"] 且您也希望返回所有包含 _Total 的实例(例如 _Total、0,_Total 等,如果适用(Processor Information 是一个例子))时才有效。
WarnOnMissing (可选)
此键是可选的。它是一个简单的布尔值。如果未设置为 true 或未包含,则默认为 false。这仅在插件首次执行时生效。它将打印出所有请求的但未匹配的 ObjectName/Instance/Counter 组合。在调试新配置时很有用。
FailOnMissing (内部)
此键不应使用。它仅用于测试目的。它是一个简单的布尔值。如果未设置为 true 或未包含,则默认为 false。如果设置为 true,则当任何 ObjectName/Instances/Counters 组合无效时,插件将中止并提前结束。
查询示例
通用查询
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# Processor usage, alternative to native, reports on a per core.
ObjectName = "Processor"
Instances = ["*"]
Counters = ["% Idle Time", "% Interrupt Time", "% Privileged Time", "% User Time", "% Processor Time"]
Measurement = "win_cpu"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# Disk times and queues
ObjectName = "LogicalDisk"
Instances = ["*"]
Counters = ["% Idle Time", "% Disk Time","% Disk Read Time", "% Disk Write Time", "% User Time", "Current Disk Queue Length"]
Measurement = "win_disk"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
ObjectName = "System"
Counters = ["Context Switches/sec","System Calls/sec", "Processor Queue Length"]
Instances = ["------"]
Measurement = "win_system"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# Example query where the Instance portion must be removed to get data back, such as from the Memory object.
ObjectName = "Memory"
Counters = ["Available Bytes","Cache Faults/sec","Demand Zero Faults/sec","Page Faults/sec","Pages/sec","Transition Faults/sec","Pool Nonpaged Bytes","Pool Paged Bytes"]
Instances = ["------"] # Use 6 x - to remove the Instance bit from the query.
Measurement = "win_mem"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# more counters for the Network Interface Object can be found at
# https://msdn.microsoft.com/en-us/library/ms803962.aspx
ObjectName = "Network Interface"
Counters = ["Bytes Received/sec","Bytes Sent/sec","Packets Received/sec","Packets Sent/sec"]
Instances = ["*"] # Use 6 x - to remove the Instance bit from the query.
Measurement = "win_net"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).Active Directory 域控制器
[[inputs.win_perf_counters]]
[inputs.win_perf_counters.tags]
monitorgroup = "ActiveDirectory"
[[inputs.win_perf_counters.object]]
ObjectName = "DirectoryServices"
Instances = ["*"]
Counters = ["Base Searches/sec","Database adds/sec","Database deletes/sec","Database modifys/sec","Database recycles/sec","LDAP Client Sessions","LDAP Searches/sec","LDAP Writes/sec"]
Measurement = "win_ad" # Set an alternative measurement to win_perf_counters if wanted.
#Instances = [""] # Gathers all instances by default, specify to only gather these
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
ObjectName = "Security System-Wide Statistics"
Instances = ["*"]
Counters = ["NTLM Authentications","Kerberos Authentications","Digest Authentications"]
Measurement = "win_ad"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
ObjectName = "Database"
Instances = ["*"]
Counters = ["Database Cache % Hit","Database Cache Page Fault Stalls/sec","Database Cache Page Faults/sec","Database Cache Size"]
Measurement = "win_db"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).DFS 命名空间 + 域控制器
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# AD, DFS N, Useful if the server hosts a DFS Namespace or is a Domain Controller
ObjectName = "DFS Namespace Service Referrals"
Instances = ["*"]
Counters = ["Requests Processed","Requests Failed","Avg. Response Time"]
Measurement = "win_dfsn"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
#WarnOnMissing = false # Print out when the performance counter is missing, either of object, counter or instance.DFS 复制 + 域控制器
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# AD, DFS R, Useful if the server hosts a DFS Replication folder or is a Domain Controller
ObjectName = "DFS Replication Service Volumes"
Instances = ["*"]
Counters = ["Data Lookups","Database Commits"]
Measurement = "win_dfsr"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
#WarnOnMissing = false # Print out when the performance counter is missing, either of object, counter or instance.DNS 服务器 + 域控制器
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
ObjectName = "DNS"
Counters = ["Dynamic Update Received","Dynamic Update Rejected","Recursive Queries","Recursive Queries Failure","Secure Update Failure","Secure Update Received","TCP Query Received","TCP Response Sent","UDP Query Received","UDP Response Sent","Total Query Received","Total Response Sent"]
Instances = ["------"]
Measurement = "win_dns"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).IIS / ASP.NET
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# HTTP Service request queues in the Kernel before being handed over to User Mode.
ObjectName = "HTTP Service Request Queues"
Instances = ["*"]
Counters = ["CurrentQueueSize","RejectedRequests"]
Measurement = "win_http_queues"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# IIS, ASP.NET Applications
ObjectName = "ASP.NET Applications"
Counters = ["Cache Total Entries","Cache Total Hit Ratio","Cache Total Turnover Rate","Output Cache Entries","Output Cache Hits","Output Cache Hit Ratio","Output Cache Turnover Rate","Compilations Total","Errors Total/Sec","Pipeline Instance Count","Requests Executing","Requests in Application Queue","Requests/Sec"]
Instances = ["*"]
Measurement = "win_aspnet_app"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# IIS, ASP.NET
ObjectName = "ASP.NET"
Counters = ["Application Restarts","Request Wait Time","Requests Current","Requests Queued","Requests Rejected"]
Instances = ["*"]
Measurement = "win_aspnet"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# IIS, Web Service
ObjectName = "Web Service"
Counters = ["Get Requests/sec","Post Requests/sec","Connection Attempts/sec","Current Connections","ISAPI Extension Requests/sec"]
Instances = ["*"]
Measurement = "win_websvc"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# Web Service Cache / IIS
ObjectName = "Web Service Cache"
Counters = ["URI Cache Hits %","Kernel: URI Cache Hits %","File Cache Hits %"]
Instances = ["*"]
Measurement = "win_websvc_cache"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).进程
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# Process metrics, in this case for IIS only
ObjectName = "Process"
Counters = ["% Processor Time","Handle Count","Private Bytes","Thread Count","Virtual Bytes","Working Set"]
Instances = ["w3wp"]
Measurement = "win_proc"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*)..NET 监控
[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# .NET CLR Exceptions, in this case for IIS only
ObjectName = ".NET CLR Exceptions"
Counters = ["# of Exceps Thrown / sec"]
Instances = ["w3wp"]
Measurement = "win_dotnet_exceptions"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# .NET CLR Jit, in this case for IIS only
ObjectName = ".NET CLR Jit"
Counters = ["% Time in Jit","IL Bytes Jitted / sec"]
Instances = ["w3wp"]
Measurement = "win_dotnet_jit"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# .NET CLR Loading, in this case for IIS only
ObjectName = ".NET CLR Loading"
Counters = ["% Time Loading"]
Instances = ["w3wp"]
Measurement = "win_dotnet_loading"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# .NET CLR LocksAndThreads, in this case for IIS only
ObjectName = ".NET CLR LocksAndThreads"
Counters = ["# of current logical Threads","# of current physical Threads","# of current recognized threads","# of total recognized threads","Queue Length / sec","Total # of Contentions","Current Queue Length"]
Instances = ["w3wp"]
Measurement = "win_dotnet_locks"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# .NET CLR Memory, in this case for IIS only
ObjectName = ".NET CLR Memory"
Counters = ["% Time in GC","# Bytes in all Heaps","# Gen 0 Collections","# Gen 1 Collections","# Gen 2 Collections","# Induced GC","Allocated Bytes/sec","Finalization Survivors","Gen 0 heap size","Gen 1 heap size","Gen 2 heap size","Large Object Heap size","# of Pinned Objects"]
Instances = ["w3wp"]
Measurement = "win_dotnet_mem"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
[[inputs.win_perf_counters.object]]
# .NET CLR Security, in this case for IIS only
ObjectName = ".NET CLR Security"
Counters = ["% Time in RT checks","Stack Walk Depth","Total Runtime Checks"]
Instances = ["w3wp"]
Measurement = "win_dotnet_security"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).故障排除
如果您收到关于无效计数器的错误,请使用 typeperf 命令在命令行上检查计数器路径。例如 typeperf "Process(chrome*)\% Processor Time"
如果即使使用默认配置也没有产生任何指标,您可能需要修复您的性能计数器。
- 以管理员身份启动命令提示符(右键单击“以管理员身份运行”)。
- 通过键入
C:然后cd \Windows\System32进入 C:\WINDOWS\System32 目录 - 通过运行以下命令重建您的计数器值,这可能需要几分钟时间,请耐心等待:
lodctr /rMetrics
示例输出
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。