### Complete Hadoop Monitoring Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/hadoop/README.md A comprehensive example demonstrating the configuration of common settings and specific components for Hadoop monitoring. ```toml [common] useSASL = false saslUsername = "HTTP/_HOST" saslDisablePAFXFast = true saslMechanism = "gssapi" kerberosAuthType = "keytabAuth" keyTabPath = "/path/to/keytab" kerberosConfigPath = "/path/to/krb5.conf" realm = "EXAMPLE.COM" [[components]] name = "YarnResourceManager" port = 8088 processName = "org.apache.hadoop.yarn.server.resourcemanager.ResourceManager" allowRecursiveParse = true allowMetricsWhiteList = true jmxUrlSuffix = "/jmx" white_list = [ "NumActiveNMs", # 活跃的NodeManager数量 "NumUnhealthyNMs", # 不健康的NodeManager数量 "NumLostNMs", # 丢失连接的NodeManager数量 ] [[components]] name = "YarnNodeManager" port = 8042 processName = "Dproc_nodemanager" allowRecursiveParse = true allowMetricsWhiteList = true jmxUrlSuffix = "/jmx" white_list = [ "ContainersLaunched", # 已启动的容器总数 "ContainersCompleted", # 已完成的容器总数 "ContainersFailed", # 失败的容器总数 ] [[components]] name = "HadoopNameNode" port = 50070 processName = "org.apache.hadoop.hdfs.server.namenode.NameNode" allowRecursiveParse = true allowMetricsWhiteList = true jmxUrlSuffix = "/jmx" white_list = [ "FSState", # NameNode 文件系统状态(Operational/SafeMode等) "HAState", # HA状态(active/standby) "State", # NameNode 状态 ] [[components]] name = "HadoopDataNode" port = 1022 processName = "Dproc_datanode" allowRecursiveParse = true allowMetricsWhiteList = true jmxUrlSuffix = "/jmx" white_list = [ "SystemCpuLoad", # 系统CPU负载 "ProcessCpuLoad", # DataNode进程CPU负载 "HeapMemoryUsage", # JVM堆内存使用情况 ] ``` -------------------------------- ### Example Smart Device Metrics Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/smart/README.md This example shows the output format for smart device health and temperature metrics. ```text smart_device_health_ok agent_hostname=1.2.3.4 device=nvme0 model=INTEL_SSDPE2KX040T8 serial_no=PHLJ830200CH4P0DGN 1 smart_device_temp_c agent_hostname=1.2.3.4 device=nvme0 model=INTEL_SSDPE2KX040T8 serial_no=PHLJ830200CH4P0DGN 53 ``` -------------------------------- ### 389ds Metrics Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/ldap/README.md Example output for 389ds (389 Directory Server) metrics, detailing connection counts, operation statistics, and thread usage. ```text 389ds_current_connections_at_max_threads agent_hostname=zy-fat port=389 server=localhost 0 389ds_connections_max_threads agent_hostname=zy-fat port=389 server=localhost 0 389ds_add_operations agent_hostname=zy-fat port=389 server=localhost 0 389ds_dtablesize agent_hostname=zy-fat port=389 server=localhost 63936 389ds_strongauth_binds agent_hostname=zy-fat port=389 server=localhost 13 389ds_modrdn_operations agent_hostname=zy-fat port=389 server=localhost 0 389ds_maxthreads_per_conn_hits agent_hostname=zy-fat port=389 server=localhost 0 389ds_current_connections agent_hostname=zy-fat port=389 server=localhost 2 389ds_security_errors agent_hostname=zy-fat port=389 server=localhost 0 389ds_entries_sent agent_hostname=zy-fat port=389 server=localhost 13 389ds_cache_entries agent_hostname=zy-fat port=389 server=localhost 0 389ds_backends agent_hostname=zy-fat port=389 server=localhost 0 389ds_threads agent_hostname=zy-fat port=389 server=localhost 17 389ds_connections agent_hostname=zy-fat port=389 server=localhost 2 389ds_read_operations agent_hostname=zy-fat port=389 server=localhost 0 389ds_entries_returned agent_hostname=zy-fat port=389 server=localhost 13 389ds_unauth_binds agent_hostname=zy-fat port=389 server=localhost 0 389ds_search_operations agent_hostname=zy-fat port=389 server=localhost 14 389ds_simpleauth_binds agent_hostname=zy-fat port=389 server=localhost 0 389ds_operations_completed agent_hostname=zy-fat port=389 server=localhost 51 389ds_connections_in_max_threads agent_hostname=zy-fat port=389 server=localhost 0 ``` -------------------------------- ### Filecount Example Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/filecount/README.md Example of the metrics output generated by the filecount plugin, showing count, size, and file timestamps. ```text 13:25:07 filecount_count agent_hostname=host1 directory=/tmp 319 13:25:07 filecount_size_bytes agent_hostname=host1 directory=/tmp 83196547 13:25:07 filecount_oldest_file_timestamp agent_hostname=host1 directory=/tmp 0 13:25:07 filecount_newest_file_timestamp agent_hostname=host1 directory=/tmp 1692336254306413522 ``` -------------------------------- ### Supervisor Process and Instance Metrics Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/supervisor/README_en.md Example output demonstrating the format of supervisor process and instance metrics. These metrics include tags like source, port, id, name, and group, along with fields such as state, uptime, pid, and exitCode. ```text supervisor_processes,group=ExampleGroup,id=supervisor,port=9001,process=ExampleProcess,source=localhost state=20i,uptime=75958i 1659786637000000000 supervisor_instance,id=supervisor,port=9001,source=localhost state=1i 1659786637000000000 ``` -------------------------------- ### IPVS Virtual Server with fwmark Example Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/ipvs/README.md Example output for an IPVS virtual server configured using proto+addr+port and backed by two real servers. Metrics include connection counts, packet rates, and byte transfers. ```shell ipvs_virtual_server,address_family=inet,fwmark=47,netmask=32,sched=rr cps=0i,connections=0i,pkts_in=0i,pkts_out=0i,bytes_in=0i,bytes_out=0i,pps_in=0i,pps_out=0i 1541019340000000000 ipvs_real_server,address=172.18.64.220,address_family=inet,port=9000,virtual_fwmark=47 inactive_connections=0i,pkts_out=0i,bytes_out=0i,pps_in=0i,cps=0i,active_connections=0i,pkts_in=0i,bytes_in=0i,pps_out=0i,connections=0i 1541019340000000000 ipvs_real_server,address=172.18.64.219,address_family=inet,port=9000,virtual_fwmark=47 cps=0i,active_connections=0i,inactive_connections=0i,connections=0i,pkts_in=0i,bytes_out=0i,pkts_out=0i,bytes_in=0i,pps_in=0i,pps_out=0i 1541019340000000000 ``` -------------------------------- ### OpenLDAP Metrics Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/ldap/README.md Example output for OpenLDAP metrics, detailing various operational statistics and server states. ```text openldap_modify_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_referrals_statistics agent_hostname=zy-fat port=389 server=localhost 0 openldap_unbind_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_delete_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_extended_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_pdu_statistics agent_hostname=zy-fat port=389 server=localhost 42 openldap_starting_threads agent_hostname=zy-fat port=389 server=localhost 0 openldap_active_threads agent_hostname=zy-fat port=389 server=localhost 1 openldap_uptime_time agent_hostname=zy-fat port=389 server=localhost 102 openldap_bytes_statistics agent_hostname=zy-fat port=389 server=localhost 3176 openldap_compare_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_bind_operations_completed agent_hostname=zy-fat port=389 server=localhost 1 openldap_total_connections agent_hostname=zy-fat port=389 server=localhost 1002 openldap_search_operations_completed agent_hostname=zy-fat port=389 server=localhost 1 openldap_abandon_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_add_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_open_threads agent_hostname=zy-fat port=389 server=localhost 1 openldap_add_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_operations_initiated agent_hostname=zy-fat port=389 server=localhost 3 openldap_write_waiters agent_hostname=zy-fat port=389 server=localhost 0 openldap_entries_statistics agent_hostname=zy-fat port=389 server=localhost 41 openldap_modrdn_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_pending_threads agent_hostname=zy-fat port=389 server=localhost 0 openldap_max_pending_threads agent_hostname=zy-fat port=389 server=localhost 0 openldap_bind_operations_initiated agent_hostname=zy-fat port=389 server=localhost 1 openldap_max_file_descriptors_connections agent_hostname=zy-fat port=389 server=localhost 1024 openldap_compare_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_search_operations_initiated agent_hostname=zy-fat port=389 server=localhost 2 openldap_modrdn_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_read_waiters agent_hostname=zy-fat port=389 server=localhost 1 openldap_backload_threads agent_hostname=zy-fat port=389 server=localhost 1 openldap_current_connections agent_hostname=zy-fat port=389 server=localhost 1 openldap_unbind_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_delete_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_extended_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_modify_operations_initiated agent_hostname=zy-fat port=389 server=localhost 0 openldap_max_threads agent_hostname=zy-fat port=389 server=localhost 16 openldap_abandon_operations_completed agent_hostname=zy-fat port=389 server=localhost 0 openldap_operations_completed agent_hostname=zy-fat port=389 server=localhost 2 openldap_database_2_databases agent_hostname=zy-fat port=389 server=localhost 0 ``` -------------------------------- ### Global Configuration Example Source: https://context7.com/flashcatcloud/categraf/llms.txt Example TOML configuration for Categraf, covering global settings, labels, logging, batching, writers, heartbeat, and Prometheus agent mode. ```toml [global] print_configs = false # Auto-detect hostname; use "$ip", "$sn", "$hostname-$ip", or a literal string hostname = "$hostname" omit_hostname = false # Precision for timestamps: "ms" | "s" | "m" precision = "ms" # Default collection interval in seconds interval = 15 # Input providers: "local" reads conf/input.*/ directories; "http" pulls from remote URL providers = ["local"] # Max concurrent goroutines per input (default: NumCPU * 10) concurrency = -1 [global.labels] region = "us-east" env = "production" [log] file_name = "stdout" # "stdout" | "stderr" | "/var/log/categraf.log" max_size = 100 # MB before rotation max_age = 7 # days max_backups = 3 local_time = true compress = true [writer_opt] batch = 1000 # max time series per remote-write request chan_size = 1000000 # in-memory queue depth # Primary backend: Nightingale / VictoriaMetrics / Prometheus [[writers]] url = "http://nightingale:17000/prometheus/v1/write" basic_auth_user = "categraf" basic_auth_pass = "secret" timeout = 5000 # ms dial_timeout = 2500 max_idle_conns_per_host = 100 # Optional TLS # tls_ca = "/etc/categraf/ca.pem" # tls_cert = "/etc/categraf/cert.pem" # tls_key = "/etc/categraf/key.pem" # insecure_skip_verify = false # Fan-out to a second backend [[writers]] url = "http://victoriametrics:8480/insert/0/prometheus/api/v1/write" [heartbeat] enable = true url = "http://nightingale:17000/v1/n9e/heartbeat" interval = 10 # seconds [http] enable = false # enable built-in push receiver address = ":9100" run_mode = "release" # "release" | "debug" print_access = false ignore_hostname = false ignore_global_labels = false [prometheus] enable = false scrape_config_file = "/etc/categraf/conf/scrape.yaml" log_level = "info" # wal_storage_path = "/data/categraf-wal" # wal_min_duration = 2 # hours ``` -------------------------------- ### Filecount Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/filecount/README.md Configure the directories to scan, file name patterns, recursion, and size/time filters for the filecount plugin. ```toml # # collect interval # interval = 15 [[instances]] # # append some labels for series # labels = { region="cloud", product="n9e" } # # interval = global.interval * interval_times # interval_times = 1 ## Directories to gather stats about. ## This accept standard unit glob matching rules, but with the addition of ## ** as a "super asterisk". ie: ## /var/log/** -> recursively find all directories in /var/log and count files in each directories ## /var/log/*/* -> find all directories with a parent dir in /var/log and count files in each directories ## /var/log -> count all files in /var/log and all of its subdirectories ## directories = ["/var/cache/apt", "/tmp"] directories = ["/tmp", "/root"] ## Only count files that match the name pattern. Defaults to "*". file_name = "*" ## Count files in subdirectories. Defaults to true. recursive = true ## Only count regular files. Defaults to true. regular_only = true ## Follow all symlinks while walking the directory tree. Defaults to false. follow_symlinks = false ## Only count files that are at least this size. If size is ## a negative number, only count files that are smaller than the ## absolute value of size. Acceptable units are B, KiB, MiB, KB, ... ## Without quotes and units, interpreted as size in bytes. size = "0B" ## Only count files that have not been touched for at least this ## duration. If mtime is negative, only count files that have been ## touched in this duration. Defaults to "0s". mtime = "0s" ``` -------------------------------- ### IPVS Virtual Server Example Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/ipvs/README.md Example output for an IPVS virtual server configured using fwmark, backed by two real servers. Metrics include connection counts, packet rates, and byte transfers. ```shell ipvs_virtual_server,address=172.18.64.234,address_family=inet,netmask=32,port=9000,protocol=tcp,sched=rr bytes_in=0i,bytes_out=0i,pps_in=0i,pps_out=0i,cps=0i,connections=0i,pkts_in=0i,pkts_out=0i 1541019340000000000 ipvs_real_server,address=172.18.64.220,address_family=inet,port=9000,virtual_address=172.18.64.234,virtual_port=9000,virtual_protocol=tcp active_connections=0i,inactive_connections=0i,pkts_in=0i,bytes_out=0i,pps_out=0i,connections=0i,pkts_out=0i,bytes_in=0i,pps_in=0i,cps=0i 1541019340000000000 ipvs_real_server,address=172.18.64.219,address_family=inet,port=9000,virtual_address=172.18.64.234,virtual_port=9000,virtual_protocol=tcp active_connections=0i,inactive_connections=0i,pps_in=0i,pps_out=0i,connections=0i,pkts_in=0i,pkts_out=0i,bytes_in=0i,bytes_out=0i,cps=0i 1541019340000000000 ``` -------------------------------- ### Example Sockstat File Content Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/sockstat/README.md This is an example of the content found in the /proc/net/sockstat file on a Linux system. It displays current socket usage statistics. ```shell sockets: used 211 TCP: inuse 9 orphan 0 tw 19 alloc 47 mem 22 UDP: inuse 2 mem 0 UDPLITE: inuse 0 RAW: inuse 0 FRAG: inuse 0 memory 0 ``` -------------------------------- ### Example Smart Attribute Metrics Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/smart/README.md This example demonstrates the output format for specific smart attribute metrics like program fail count, erase fail count, and wear leveling count. ```text smart_attribute_program_fail_count agent_hostname=1.2.3.4 device=nvme0 model= name=Program_Fail_Count serial_no=PHLJ830200CH4P0DGN 0 smart_attribute_erase_fail_count agent_hostname=1.2.3.4 device=nvme0 model= name=Erase_Fail_Count serial_no=PHLJ830200CH4P0DGN 0 smart_attribute_wear_leveling_count agent_hostname=1.2.3.4 device=nvme0 model= name=Wear_Leveling_Count serial_no=PHLJ830200CH4P0DGN 34360328200 ``` -------------------------------- ### Run Categraf with Default Configuration Source: https://github.com/flashcatcloud/categraf/blob/main/README_en.md Start Categraf with its default configuration. ```shell ./categraf ``` -------------------------------- ### Run Categraf with Specific Plugins Enabled Source: https://github.com/flashcatcloud/categraf/blob/main/README_en.md Start Categraf and enable only the system and mem plugins. ```shell ./categraf --inputs system:mem ``` -------------------------------- ### Example Ping Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/ping/README.md Sample output metrics generated by the ping monitoring plugin for different targets. ```text ping_maximum_response_ms agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0.036 ping_packets_transmitted agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 1 ping_packets_received agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 1 ping_average_response_ms agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0.036 ping_minimum_response_ms agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0.036 ping_standard_deviation_ms agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0 ping_result_code agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0 ping_percent_packet_loss agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 0 ping_ttl agent_hostname=zy-fat product=n9e region=cloud target=10.0.24.136 64 ping_minimum_response_ms agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 20.935 ping_average_response_ms agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 20.935 ping_standard_deviation_ms agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 0 ping_result_code agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 0 ping_packets_transmitted agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 1 ping_packets_received agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 1 ping_ttl agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 50 ping_percent_packet_loss agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 0 ping_maximum_response_ms agent_hostname=zy-fat product=n9e region=cloud target=www.baidu.com 20.935 ``` -------------------------------- ### Test Specific Plugins Source: https://context7.com/flashcatcloud/categraf/llms.txt In test mode, specifies which input plugins to run. This example tests only the cpu and mem plugins. ```shell ./categraf --test --inputs cpu:mem ``` -------------------------------- ### Example Script Output Test Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/exec/README.md Demonstrates the expected output format from a sample script (`collect_cert_expiretime.sh`) when using the Influx data format. ```text cert,cloud=huaweicloud,region=huabei-beijing-4,azone=az1,product=cert,domain_name=www.baidu.com expire_days=163 cert,cloud=huaweicloud,region=huabei-beijing-4,azone=az1,product=cert,domain_name=www.weibo.com expire_days=85 cert,cloud=huaweicloud,region=huabei-beijing-4,azone=az1,product=cert,domain_name=www.csdn.net expire_days=281 ``` -------------------------------- ### Categraf Exec Plugin Configuration Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/exec/README.md Configuration example for the exec plugin in `exec.toml`. Specifies commands to execute and the data format for output. ```toml [root@aliyun input.exec]# vi exec.toml # # collect interval # interval = 15 [[instances]] # # commands, support glob commands = [ "/opt/categraf/scripts/*/collect_*.sh" #"/opt/categraf/scripts/*/collect_*.py" #"/opt/categraf/scripts/*/collect_*.go" #"/opt/categraf/scripts/*/collect_*.lua" #"/opt/categraf/scripts/*/collect_*.java" #"/opt/categraf/scripts/*/collect_*.bat" #"/opt/categraf/scripts/*/collect_*.cmd" #"/opt/categraf/scripts/*/collect_*.ps1" ] # # timeout for each command to complete # timeout = 5 # # interval = global.interval * interval_times # interval_times = 1 # # mesurement,labelkey1=labelval1,labelkey2=labelval2 field1=1.2,field2=2.3 data_format = "influx" ``` -------------------------------- ### mtail Pattern Matching Examples Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/mtail/Readme.md Demonstrates mtail pattern matching using regular expressions and variable conditions. Supports combining patterns with logical operators. ```golang /foo/ { ACTION1 } variable > 0 { ACTION2 } /foo/ && variable > 0 { ACTION3 } ``` ```golang const PREFIX /^\w+\W+\d+ / PREFIX { ACTION1 } PREFIX + /foo/ { ACTION2 } ``` -------------------------------- ### Example Tengine Metrics Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/tengine/README.md Sample output format for metrics collected by the Tengine plugin. Each line represents a specific metric with associated tags. ```text tengine_rt agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 37634 tengine_ups_rt agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 37394 tengine_http_499 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 0 tengine_http_504 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 0 tengine_bytes_in agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 129592 tengine_http_4xx agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=http target=127.0.0.1 target_port=80 535 tengine_http_other_status agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 0 tengine_http_200 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 14452 tengine_http_499 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 0 tengine_http_503 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 0 tengine_http_504 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 0 tengine_http_500 agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 0 tengine_http_ups_4xx agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 13 tengine_http_ups_5xx agent_hostname=zy-fat project=matrix server_name=www.baidu.com server_schema=https target=127.0.0.1 target_port=80 1 ``` -------------------------------- ### Prometheus Data Format Example Script Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/exec/README.md A shell script demonstrating how to output metrics in Prometheus format. Categraf ignores lines starting with '#'. ```shell #!/bin/sh echo '# HELP demo_http_requests_total Total number of http api requests' echo '# TYPE demo_http_requests_total counter' echo 'demo_http_requests_total{api="add_product"} 4633433' ``` -------------------------------- ### Tomcat Collector Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/tomcat/README.md This TOML configuration sets up the Tomcat collector to gather metrics from a specified Tomcat server URL using basic authentication. Adjust the URL, username, and password to match your Tomcat setup. ```toml # # collect interval # interval = 15 # Gather metrics from the Tomcat server status page. [[instances]] ## URL of the Tomcat server status url = "http://127.0.0.1:8080/manager/status/all?XML=true" ## HTTP Basic Auth Credentials username = "tomcat" password = "s3cret" ## Request timeout # timeout = "5s" # # interval = global.interval * interval_times # interval_times = 1 # important! use global unique string to specify instance # labels = { instance="192.168.1.2:8080", url="-" } ## Optional TLS Config # use_tls = false # tls_min_version = "1.2" # tls_ca = "/etc/categraf/ca.pem" # tls_cert = "/etc/categraf/cert.pem" # tls_key = "/etc/categraf/key.pem" ## Use TLS but skip chain & host verification # insecure_skip_verify = true ``` -------------------------------- ### Using types.Sample and types.SampleList in Go Source: https://context7.com/flashcatcloud/categraf/llms.txt Demonstrates creating and populating SampleList with individual and multiple samples. Samples are automatically converted to prompb.TimeSeries for dispatch. ```go import ( "time" "flashcat.cloud/categraf/types" ) // Create a sample list (done automatically by the agent, shown for clarity) slist := types.NewSampleList() // Push a single named sample s := types.NewSample("myapp", "request_duration_seconds", 0.235, map[string]string{"method": "GET", "path": "/api/v1/users"}, ) s.SetTime(time.Now()) slist.PushSample("myapp", "request_duration_seconds", 0.235, map[string]string{"method": "GET", "path": "/api/v1/users"}, ) // Push multiple fields at once (adds metric_name prefix to each field) slist.PushSamples("http_server", map[string]interface{}{ "requests_total": 12345.0, "errors_total": 42.0, "latency_p99_ms": 180.5, }, map[string]string{ "handler": "/api", "status": "200", }) // Drain all samples for writing samples := slist.PopBackAll() // → []*types.Sample ready to pass to writer.WriteSamples(samples) ``` -------------------------------- ### Get Specific CloudWatch Metric Data using AWS CLI Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/cloudwatch/README.md Retrieve specific metric data using the AWS CLI with defined start and end times, metric details, and statistics. This helps in debugging and verifying metric retrieval. ```shell aws cloudwatch get-metric-data \ --start-time 2018-07-01T00:00:00Z \ --end-time 2018-07-01T00:15:00Z \ --metric-data-queries '[\ {\ "Id": "avgCPUCreditBalance",\ "MetricStat": {\ "Metric": {\ "Namespace": "AWS/EC2",\ "MetricName": "CPUCreditBalance",\ "Dimensions": [\ {\ "Name": "InstanceId",\ "Value": "i-deadbeef"\ }\ ] }, "Period": 300, "Stat": "Average" }, "Label": "avgCPUCreditBalance" }]' ``` -------------------------------- ### Install Categraf as User Service Source: https://context7.com/flashcatcloud/categraf/llms.txt Installs Categraf as a system service running under the current user's privileges, useful for non-root installations. ```shell ./categraf --install --user ``` -------------------------------- ### Example gNMI Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/gnmi/README.md This is an example of the output format generated by Categraf for gNMI interface counters. ```text ifcounters,path=openconfig-interfaces:/interfaces/interface/state/counters,host=linux,name=MgmtEth0/RP0/CPU0/0,source=10.49.234.115,descr/description=Foo in-multicast-pkts=0i,out-multicast-pkts=0i,out-errors=0i,out-discards=0i,in-broadcast-pkts=0i,out-broadcast-pkts=0i,in-discards=0i,in-unknown-protos=0i,in-errors=0i,out-unicast-pkts=0i,in-octets=0i,out-octets=0i,last-clear="2019-05-22T16:53:21Z",in-unicast-pkts=0i 1559145777425000000 ifcounters,path=openconfig-interfaces:/interfaces/interface/state/counters,host=linux,name=GigabitEthernet0/0/0/0,source=10.49.234.115,descr/description=Bar out-multicast-pkts=0i,out-broadcast-pkts=0i,in-errors=0i,out-errors=0i,in-discards=0i,out-octets=0i,in-unknown-protos=0i,in-unicast-pkts=0i,in-octets=0i,in-multicast-pkts=0i,in-broadcast-pkts=0i,last-clear="2019-05-22T16:54:50Z",out-unicast-pkts=0i,out-discards=0i 1559145777425000000 ``` -------------------------------- ### mtail Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/mtail/Readme.md Configure mtail instances, specifying the directory for mtail programs, the logs to read, and optional settings like timezone and metric timestamp emission. ```toml [[instances]] ## 指定mtail prog的目录 progs = "/path/to/prog1" ## 指定mtail要读取的日志 logs = ["/path/to/a.log", "path/to/b.log"] ## 指定时区 # override_timezone = "Asia/Shanghai" ## metrics是否带时间戳,注意,这是"true" # emit_metric_timestamp = "true" ... ``` -------------------------------- ### HTTP Instance Configuration with Method Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/http_response/README.md Configures multiple HTTP instances, specifying the HTTP method for each. ```toml [[instances]] targets = [ "http://localhost:8080", "https://www.baidu.com" ] method = "GET" [[instances]] targets = [ "http://localhost:9090" ] method = "POST" ``` -------------------------------- ### Include Specific CPU Metrics Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/supervisor/README_en.md Configuration example to include only specific CPU metrics like idle time and user time. This helps in optimizing data collection. ```toml [[instances]] ## Only collect metrics of CPU's idle time and user time metrics_include = ["cpu_usage_idle", "cpu_usage_user"] ``` -------------------------------- ### Example AMD ROCm SMI Output Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/amd_rocm_smi/README.md Example of the metrics collected by the amd_rocm_smi plugin, showing GPU details and performance indicators. ```text amd_rocm_smi,gpu_id=0x6861,gpu_unique_id=0x2150e7d042a1124,host=ali47xl,name=card0 clocks_current_memory=167i,clocks_current_sm=852i,driver_version=51114i,fan_speed=14i,memory_free=17145282560i,memory_total=17163091968i,memory_used=17809408i,power_draw=7,temperature_sensor_edge=28,temperature_sensor_junction=29,temperature_sensor_memory=92,utilization_gpu=0i 1630572551000000000 amd_rocm_smi,gpu_id=0x6861,gpu_unique_id=0x2150e7d042a1124,host=ali47xl,name=card0 clocks_current_memory=167i,clocks_current_sm=852i,driver_version=51114i,fan_speed=14i,memory_free=17145282560i,memory_total=17163091968i,memory_used=17809408i,power_draw=7,temperature_sensor_edge=29,temperature_sensor_junction=30,temperature_sensor_memory=91,utilization_gpu=0i 1630572701000000000 amd_rocm_smi,gpu_id=0x6861,gpu_unique_id=0x2150e7d042a1124,host=ali47xl,name=card0 clocks_current_memory=167i,clocks_current_sm=852i,driver_version=51114i,fan_speed=14i,memory_free=17145282560i,memory_total=17163091968i,memory_used=17809408i,power_draw=7,temperature_sensor_edge=29,temperature_sensor_junction=29,temperature_sensor_memory=92,utilization_gpu=0i 1630572749000000000 ``` -------------------------------- ### Basic HTTP Instance Configuration Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/http_response/README.md Configures a single HTTP instance with multiple target URLs. ```toml [[instances]] targets = [ "http://localhost:8080", "https://www.baidu.com" ] ``` -------------------------------- ### Cadvisor Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/cadvisor/README.md Configure the cadvisor plugin to collect metrics. Specify the URL for the cadvisor endpoint or kubelet, authentication methods, and label filtering options. ```toml # # collect interval # interval = 15 [[instances]] # 填写kubelet的ip和port url = "https://1.2.3.4:10250/metrics/cadvisor" # 如果path为空, 会自动补齐为/metrics/cadvisor # url = "https://1.2.3.4:10250" # 如果是通过kubelet采集,可以附加pod的label和annotation type = "kubelet" # 直接采集cadvisor , type 设置为cadvisor #url = "http://1.2.3.4:8080/metrics" #type = "cadvisor" # url_label_key 和 url_label_value 用法参加下面说明 url_label_key = "instance" url_label_value = "{{.Host}}" # # 认证的token 或者token file #bearer_token_string = "eyJhblonglongXXX.eyJplonglongYYY.oQsXlonglongZ-Z-Z" bearer_token_file = "/path/to/token/file" # 需要忽略的label key ignore_label_keys = ["id","name", "container_label*"] # 只采集那些label key, 建议保持为空,采集所有的label。 优先级高于ignore_label_keys。 # 放开choose_label_keys配置时,如果不使用["*"], 需要里面包含"pod","namespace",否则采集不到pod标签,例如:["app","pod","namespace"] #choose_label_keys = ["*"] timeout = "3s" # # Optional TLS Config # # 想跳过自签证书,use_tls 记得要配置为true use_tls = true # tls_min_version = "1.2" # tls_ca = "/etc/categraf/ca.pem" # tls_cert = "/etc/categraf/cert.pem" # tls_key = "/etc/categraf/key.pem" ## Use TLS but skip chain & host verification insecure_skip_verify = true ``` -------------------------------- ### Falcon Data Format Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/exec/README.md Provides an example of the Open-Falcon data format. Categraf ignores 'timestamp', 'step', and 'counterType' fields, and 'endpoint' is added to labels. ```json [ { "endpoint": "test-endpoint", "metric": "test-metric", "timestamp": 1658490609, "step": 60, "value": 1, "counterType": "GAUGE", "tags": "idc=lg,loc=beijing", }, { "endpoint": "test-endpoint", "metric": "test-metric2", "timestamp": 1658490609, "step": 60, "value": 2, "counterType": "GAUGE", "tags": "idc=lg,loc=beijing", } ] ``` -------------------------------- ### Example Zabbix YAML Template Structure Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/snmp_zabbix/README.md This is a structural example of a Zabbix YAML template, illustrating the organization of template information, including items, discovery rules, and macros. ```yaml zabbix_export: version: '7.0' date: '2024-01-15T10:00:00Z' templates: - template: Template Net Example Device name: Template Net Example Device description: Template for monitoring example network device groups: - name: Templates/Network devices items: # 监控项 - name: Interface {#IFNAME} incoming traffic type: SNMP_AGENT snmp_oid: .1.3.6.1.2.1.2.2.1.10.{#SNMPINDEX} key: net.if.in[{#IFNAME}] delay: 60s value_type: UNSIGNED units: bps preprocessing: - type: CHANGE_PER_SECOND discovery_rules: # 发现规则 - name: Network interfaces discovery type: SNMP_AGENT snmp_oid: discovery[{#IFNAME},.1.3.6.1.2.1.2.2.1.2] key: net.if.discovery delay: 1h filter: conditions: - macro: '{#IFNAME}' value: '{$NET.IF.NAME.MATCHES}' #value: '^(eth|bond|eno|ens)' # 直接这么写也行,上一行的写法只是为了用户宏的说明 operator: MATCHES_REGEX item_prototypes: # 项目原型 - name: 'Interface {#IFNAME}: Bits received' type: SNMP_AGENT snmp_oid: .1.3.6.1.2.1.2.2.1.10.{#SNMPINDEX} key: net.if.in[{#IFNAME}] macros: # 用户宏 - macro: '{$NET.IF.NAME.MATCHES}' value: '^(eth|bond|eno|ens)' ``` -------------------------------- ### Configure URL Label Value with Scheme, Host, and Path Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/prometheus/README.md This configuration demonstrates using Go template to include the scheme, host, and path in the URL label value. ```ini url_label_value = "{{.Scheme}}://{{.Host}}{{.Path}}" ``` -------------------------------- ### CloudWatch Configuration Example Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/cloudwatch/README.md This TOML snippet shows a sample configuration for the CloudWatch input plugin. It includes basic settings for region, profile, and namespaces. Ensure your AWS credentials are configured correctly for the plugin to authenticate. ```toml [[inputs.cloudwatch]] region = "us-east-1" profile = "default" # namespaces = ["AWS/EC2", "AWS/ELB"] # You can also specify a specific profile to use for authentication # profile = "my-profile" # You can also specify a role_arn to assume # role_arn = "arn:aws:iam::123456789012:role/MyRole" # You can also specify explicit credentials # access_key = "YOUR-ACCESSKEY" # secret_key = "YOUR-SECRETKEY" # token = "YOUR-TOKEN" # Optional: Specify specific metrics to collect # [[inputs.cloudwatch.metric]] # namespace = "AWS/EC2" # name = "CPUUtilization" # dimensions = {"InstanceId" = "i-0123456789abcdef0"} # statistic = "Average" # unit = "Percent" # alias = "ec2_cpu_utilization" ``` -------------------------------- ### Exec Input Plugin Script Example Source: https://context7.com/flashcatcloud/categraf/llms.txt Example shell script for the Exec input plugin that outputs metrics in Influx line protocol format. It collects Redis queue depth and active worker counts. ```bash #!/bin/bash # /opt/scripts/custom_metrics.sh (Influx line-protocol output) # Format: measurement[,tag1=v1,...] field1=v1[,field2=v2] [timestamp_ns] QUEUE_DEPTH=$(redis-cli llen job_queue) ACTIVE_WORKERS=$(pgrep -c worker_process || echo 0) echo "app_queue,app=billing depth=${QUEUE_DEPTH},workers=${ACTIVE_WORKERS}" ``` -------------------------------- ### Expected CPU Plugin Output (Test Mode) Source: https://context7.com/flashcatcloud/categraf/llms.txt Example of the stdout output when testing the CPU input plugin. Metrics include user, system, idle, iowait, steal, and active percentages. ```shell # Expected stdout output (test mode): # 1700000000 15:06:40 cpu_usage_user cpu=cpu-total agent_hostname=web-01 3.2 # 1700000000 15:06:40 cpu_usage_system cpu=cpu-total agent_hostname=web-01 1.1 # 1700000000 15:06:40 cpu_usage_idle cpu=cpu-total agent_hostname=web-01 95.7 # 1700000000 15:06:40 cpu_usage_iowait cpu=cpu-total agent_hostname=web-01 0.0 # 1700000000 15:06:40 cpu_usage_steal cpu=cpu-total agent_hostname=web-01 0.0 # 1700000000 15:06:40 cpu_usage_active cpu=cpu-total agent_hostname=web-01 4.3 ``` -------------------------------- ### Basic Redis Instance Configuration Source: https://github.com/flashcatcloud/categraf/blob/main/inputs/redis/README.md Configure a single Redis instance for monitoring. Ensure the address is correctly set. ```toml [[instances]] address = "127.0.0.1:6379" username = "" password = "" labels = { instance="n9e-10.23.25.2:6379" } ``` -------------------------------- ### Print Version Source: https://context7.com/flashcatcloud/categraf/llms.txt Prints the installed version of Categraf. No configuration is required. ```shell ./categraf --version ``` -------------------------------- ### Build Categraf Source: https://github.com/flashcatcloud/categraf/blob/main/README_en.md Build the Categraf binary. Ensure GO111MODULE and GOPROXY are set if needed. ```shell # export GO111MODULE=on # export GOPROXY=https://goproxy.cn go build ```