{"id":35934,"date":"2022-12-21T00:06:25","date_gmt":"2024-03-04T00:36:53","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/"},"modified":"2024-04-29T06:14:53","modified_gmt":"2024-04-28T22:14:53","slug":"prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/","title":{"rendered":"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316"},"content":{"rendered":"<h6>\u6267\u884c\u73af\u5883\uff1a<\/h6>\n<pre class=\"post-pre\"><code>[root@testhost ~]# uname -a\r\nLinux testhost 4.18.0-448.el8.x86_64 #1 SMP Wed Jan 18 15:02:46 UTC 2023 x86_64 x86_64 x86_64 GNU\/Linux\r\n[root@testhost ~]# cat \/etc\/redhat-release\r\nCentOS Stream release 8\r\n[root@testhost ~]# yum list installed | grep telegraf\r\ntelegraf.x86_64                                    1.28.3-1                                                   @@commandline\r\n[root@testhost ~]# yum list installed | grep influxdb\r\ninfluxdb2.x86_64                                   2.7.3-1                                                    @@commandline\r\n[root@testhost ~]# yum list installed | grep grafana\r\ngrafana-enterprise.x86_64                          10.0.3-1                                                   @@commandline \r\n<\/code><\/pre>\n<p>node_exporter \u7248\u672c\uff1a1.6.1.linux-amd64<\/p>\n<h3>0. \u6982\u8ff0<\/h3>\n<p>\u5728\u80fd\u591f\u76d1\u63a7\u7cfb\u7edf\u6027\u80fd\u4fe1\u606f\u7684\u8f6f\u4ef6\u4e2d\uff0c\u5b58\u5728\u7740\u5404\u79cd\u5404\u6837\u7684\u9009\u62e9\u3002<br \/>\n\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f Prometheus\uff0c\u5b83\u5907\u53d7\u5173\u6ce8\u4f5c\u4e3a\u9002\u7528\u4e8e\u4e91\u73af\u5883\u7684\u8f6f\u4ef6\u3002<\/p>\n<p>Promtheus<\/p>\n<p>\u7136\u800c\uff0c\u8fd9\u4e2a Prometheus \u5e76\u4e0d\u592a\u9002\u5408\u957f\u671f\u6570\u636e\u4fdd\u5b58\u3002<br \/>\n\u5982\u679c\u60f3\u8981\u957f\u671f\u4fdd\u5b58\u83b7\u53d6\u5230\u7684\u6570\u636e\uff0c\u5c31\u9700\u8981\u5c06\u6570\u636e\u5b58\u50a8\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u3082\u69d8\u3005\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e1\u3064\u304c\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\u306b\u7279\u5316\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u3042\u308b InfluxDB \u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306e InfluxDB \u306b\u3001 Prometheus \u304b\u3089\u53d6\u308a\u8fbc\u3093\u3060\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>InfluxDB<\/p>\n<p>\u3068\u3053\u308d\u304c\u3001 Prometheus \u3068 InfluxDB \u306e\u63a5\u7d9a\u306f\u3001\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u6700\u65b0\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3042\u304d\u3089\u3081\u308b\u3057\u304b\u306a\u3044\u306e\u304b\u3068\u3044\u3046\u3068\u3001\u5b9f\u306f\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u304c\u6b8b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u3046\u3061\u306e1\u3064\u304c\u3001 InfluxDB \u5411\u3051\u306b\u4f5c\u6210\u3055\u308c\u305f\u30e1\u30c8\u30ea\u30af\u30b9\u53ce\u96c6\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3067\u3042\u308b Telegraf \u3092\u7528\u3044\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u7535\u62a5<\/p>\n<p>\u7531\u4e8eTelegraf\u652f\u6301\u4f5c\u4e3a\u83b7\u53d6\u6570\u636e\u7684\u6e90\u5934\uff0c\u56e0\u6b64\u901a\u8fc7\u4f7f\u7528Telegraf\u53ef\u4ee5\u95f4\u63a5\u5730\u5c06Prometheus\u548cInfluxDB\u8fde\u63a5\u8d77\u6765\u3002<\/p>\n<p>\u4eca\u56de\u306f Telegraf \u3092\u4f7f\u3063\u3066 Prometheus \u3067\u53d6\u5f97\u3057\u305f\u60c5\u5831\u3092 InfluxDB \u306b\u683c\u7d0d\u3057\u3001\u3064\u3044\u3067\u306b\u683c\u7d0d\u3057\u305f\u30c7\u30fc\u30bf\u3092 Grafana \u3067\u53ef\u8996\u5316\u3059\u308b\u3053\u3068\u3092\u76ee\u6307\u3057\u307e\u3059\u3002<\/p>\n<p>Grafana<\/p>\n<h3>1. \u9810\u5148\u6e96\u5099<\/h3>\n<p>Prometheus \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u904e\u53bb\u8a18\u4e8b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u306a\u304a\u3001\u5fc5\u8981\u306a\u306e\u306f\u300c node_exporter \u300d\u3060\u3051\u3067\u3001\u4ed6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u4e0d\u8981\u3067\u3059\u3002<\/p>\n<p>\u5c1d\u8bd5\u514d\u8d39\u5b89\u88c5Linux\u7cfb\u7edf\u76d1\u63a7\u8f6f\u4ef6\u201cPrometheus\u201d<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u8fc7\u53bb\u6587\u7ae0\uff0c\u83b7\u53d6\u6709\u5173 InfluxDB \u548c Grafana \u5b89\u88c5\u7684\u4fe1\u606f\u3002<\/p>\n<p>Linux: \u30c7\u30fc\u30bf\u53ef\u8996\u5316\u30bd\u30d5\u30c8\u300cGrafana\u300d\u3092\u7121\u6599\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\uff0b\u300cPrometheus\u300d\u3068\u9023\u643a\u3055\u305b\u3066\u307f\u305f<\/p>\n<p>Linux: \u6211\u8bd5\u7740\u514d\u8d39\u5b89\u88c5\u4e86\u4e13\u6ce8\u4e8e\u65f6\u95f4\u7cfb\u5217\u6570\u636e\u7684\u6570\u636e\u5e93&#8221;InfluxDB&#8221;\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u8fc7\u53bb\u6587\u7ae0\u4e86\u89e3\u5173\u4e8eTelegraf\u5b89\u88c5\u548c\u4e0eInfluxDB\u7684\u96c6\u6210\u3002<\/p>\n<p>InfluxDB: \u4eceTelegraf\u83b7\u53d6\u6570\u636e\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u6709\u5173 InfluxDB \u548c Grafana \u96c6\u6210\u7684\u8fc7\u53bb\u6587\u7ae0\u3002<\/p>\n<p>InfluxDB: \u30c7\u30fc\u30bf\u3092Grafana\u3067\u53ef\u8996\u5316\u3057\u3066\u307f\u308b<\/p>\n<p>\u53e6\u5916\uff0c\u672c\u6587\u7684\u524d\u63d0\u662f\u6240\u6709\u8f6f\u4ef6\u90fd\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u3002<br \/>\n\u540c\u65f6\uff0c\u8bbe\u7f6e\u65b9\u9762\u5c06\u9075\u5faa\u8fd9\u4e9b\u8fc7\u53bb\u6587\u7ae0\u7684\u89c4\u5b9a\u3002<\/p>\n<h3>2. \u8bbe\u7f6e<\/h3>\n<p>\u4eca\u56de\u5fc5\u8981\u3068\u306a\u308b\u306e\u306f\u3001 Telegraf \u306e\u8a2d\u5b9a\u5909\u66f4\u3067\u3059\u3002<br \/>\n\u8a2d\u5b9a\u5909\u66f4\u524d\u306b\u3001 Telegraf \u306f\u3044\u3063\u305f\u3093\u505c\u6b62\u3055\u305b\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>Telegraf \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb \/etc\/telegraf\/telegraf.conf \u306e\u4e2d\u3067\u3001 Prometheus \u306b\u95a2\u3059\u308b\u7b87\u6240\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># # Read metrics from one or many prometheus clients\r\n# [[inputs.prometheus]]\r\n#   ## An array of urls to scrape metrics from.\r\n#   urls = [\"http:\/\/localhost:9100\/metrics\"]\r\n#\r\n#   ## Metric version controls the mapping from Prometheus metrics into Telegraf metrics.\r\n#   ## See \"Metric Format Configuration\" in plugins\/inputs\/prometheus\/README.md for details.\r\n#   ## Valid options: 1, 2\r\n#   # metric_version = 1\r\n#\r\n#   ## Url tag name (tag containing scrapped url. optional, default is \"url\")\r\n#   # url_tag = \"url\"\r\n#\r\n#   ## Whether the timestamp of the scraped metrics will be ignored.\r\n#   ## If set to true, the gather time will be used.\r\n#   # ignore_timestamp = false\r\n#\r\n#   ## An array of Kubernetes services to scrape metrics from.\r\n#   # kubernetes_services = [\"http:\/\/my-service-dns.my-namespace:9100\/metrics\"]\r\n#\r\n#   ## Kubernetes config file to create client from.\r\n#   # kube_config = \"\/path\/to\/kubernetes.config\"\r\n#\r\n#   ## Scrape Pods\r\n#   ## Enable scraping of k8s pods. Further settings as to which pods to scape\r\n#   ## are determiend by the 'method' option below. When enabled, the default is\r\n#   ## to use annotations to determine whether to scrape or not.\r\n#   # monitor_kubernetes_pods = false\r\n#\r\n#   ## Scrape Pods Method\r\n#   ## annotations: default, looks for specific pod annotations documented below\r\n#   ## settings: only look for pods matching the settings provided, not\r\n#   ##   annotations\r\n#   ## settings+annotations: looks at pods that match annotations using the user\r\n#   ##   defined settings\r\n#   # monitor_kubernetes_pods_method = \"annotations\"\r\n#\r\n#   ## Scrape Pods 'annotations' method options\r\n#   ## If set method is set to 'annotations' or 'settings+annotations', these\r\n#   ## annotation flags are looked for:\r\n#   ## - prometheus.io\/scrape: Required to enable scraping for this pod. Can also\r\n#   ##     use 'prometheus.io\/scrape=false' annotation to opt-out entirely.\r\n#   ## - prometheus.io\/scheme: If the metrics endpoint is secured then you will\r\n#   ##     need to set this to 'https' &amp; most likely set the tls config\r\n#   ## - prometheus.io\/path: If the metrics path is not \/metrics, define it with\r\n#   ##     this annotation\r\n#   ## - prometheus.io\/port: If port is not 9102 use this annotation\r\n#\r\n#   ## Scrape Pods 'settings' method options\r\n#   ## When using 'settings' or 'settings+annotations', the default values for\r\n#   ## annotations can be modified using with the following options:\r\n#   # monitor_kubernetes_pods_scheme = \"http\"\r\n#   # monitor_kubernetes_pods_port = \"9102\"\r\n#   # monitor_kubernetes_pods_path = \"\/metrics\"\r\n#\r\n#   ## Get the list of pods to scrape with either the scope of\r\n#   ## - cluster: the kubernetes watch api (default, no need to specify)\r\n#   ## - node: the local cadvisor api; for scalability. Note that the config node_ip or the environment variable NODE_IP must be set to the host IP.\r\n#   # pod_scrape_scope = \"cluster\"\r\n#\r\n#   ## Only for node scrape scope: node IP of the node that telegraf is running on.\r\n#   ## Either this config or the environment variable NODE_IP must be set.\r\n#   # node_ip = \"10.180.1.1\"\r\n#\r\n#   ## Only for node scrape scope: interval in seconds for how often to get updated pod list for scraping.\r\n#   ## Default is 60 seconds.\r\n#   # pod_scrape_interval = 60\r\n#\r\n#   ## Restricts Kubernetes monitoring to a single namespace\r\n#   ##   ex: monitor_kubernetes_pods_namespace = \"default\"\r\n#   # monitor_kubernetes_pods_namespace = \"\"\r\n#   ## The name of the label for the pod that is being scraped.\r\n#   ## Default is 'namespace' but this can conflict with metrics that have the label 'namespace'\r\n#   # pod_namespace_label_name = \"namespace\"\r\n#   # label selector to target pods which have the label\r\n#   # kubernetes_label_selector = \"env=dev,app=nginx\"\r\n#   # field selector to target pods\r\n#   # eg. To scrape pods on a specific node\r\n#   # kubernetes_field_selector = \"spec.nodeName=$HOSTNAME\"\r\n#\r\n#   ## Filter which pod annotations and labels will be added to metric tags\r\n#   #\r\n#   # pod_annotation_include = [\"annotation-key-1\"]\r\n#   # pod_annotation_exclude = [\"exclude-me\"]\r\n#   # pod_label_include = [\"label-key-1\"]\r\n#   # pod_label_exclude = [\"exclude-me\"]\r\n#\r\n#   # cache refresh interval to set the interval for re-sync of pods list.\r\n#   # Default is 60 minutes.\r\n#   # cache_refresh_interval = 60\r\n#\r\n#   ## Scrape Services available in Consul Catalog\r\n#   # [inputs.prometheus.consul]\r\n#   #   enabled = true\r\n#   #   agent = \"http:\/\/localhost:8500\"\r\n#   #   query_interval = \"5m\"\r\n#\r\n#   #   [[inputs.prometheus.consul.query]]\r\n#   #     name = \"a service name\"\r\n#   #     tag = \"a service tag\"\r\n#   #     url = 'http:\/\/{{if ne .ServiceAddress \"\"}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}\/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'\r\n#   #     [inputs.prometheus.consul.query.tags]\r\n#   #       host = \"{{.Node}}\"\r\n#\r\n#   ## Use bearer token for authorization. ('bearer_token' takes priority)\r\n#   # bearer_token = \"\/path\/to\/bearer\/token\"\r\n#   ## OR\r\n#   # bearer_token_string = \"abc_123\"\r\n#\r\n#   ## HTTP Basic Authentication username and password. ('bearer_token' and\r\n#   ## 'bearer_token_string' take priority)\r\n#   # username = \"\"\r\n#   # password = \"\"\r\n#\r\n#   ## Optional custom HTTP headers\r\n#   # http_headers = {\"X-Special-Header\" = \"Special-Value\"}\r\n#\r\n#   ## Specify timeout duration for slower prometheus clients (default is 5s)\r\n#   # timeout = \"5s\"\r\n#\r\n#   ## deprecated in 1.26; use the timeout option\r\n#   # response_timeout = \"5s\"\r\n#\r\n#   ## HTTP Proxy support\r\n#   # use_system_proxy = false\r\n#   # http_proxy_url = \"\"\r\n#\r\n#   ## Optional TLS Config\r\n#   # tls_ca = \/path\/to\/cafile\r\n#   # tls_cert = \/path\/to\/certfile\r\n#   # tls_key = \/path\/to\/keyfile\r\n#\r\n#   ## Use TLS but skip chain &amp; host verification\r\n#   # insecure_skip_verify = false\r\n#\r\n#   ## Use the given name as the SNI server name on each URL\r\n#   # tls_server_name = \"myhost.example.org\"\r\n#\r\n#   ## TLS renegotiation method, choose from \"never\", \"once\", \"freely\"\r\n#   # tls_renegotiation_method = \"never\"\r\n#\r\n#   ## Enable\/disable TLS\r\n#   ## Set to true\/false to enforce TLS being enabled\/disabled. If not set,\r\n#   ## enable TLS only if any of the other options are specified.\r\n#   # tls_enable = true\r\n#\r\n#   ## Control pod scraping based on pod namespace annotations\r\n#   ## Pass and drop here act like tagpass and tagdrop, but instead\r\n#   ## of filtering metrics they filters pod candidates for scraping\r\n#   #[inputs.prometheus.namespace_annotation_pass]\r\n#   # annotation_key = [\"value1\", \"value2\"]\r\n#   #[inputs.prometheus.namespace_annotation_drop]\r\n#   # some_annotation_key = [\"dont-scrape\"]\r\n<\/span><\/code><\/pre>\n<p>\u867d\u7136\u975e\u5e38\u957f\uff0c\u4f46\u91cd\u8981\u7684\u662f\u524d\u4e24\u884c\u3002<br \/>\n\u9996\u5148\uff0c\u53d6\u6d88[[inputs.prometheus]]\u7684\u6ce8\u91ca\u3002<br \/>\n\u7136\u540e\u53d6\u6d88urls\u7684\u6ce8\u91ca\uff0c\u5e76\u6307\u5b9aPrometheus\uff08node_exporter\uff09\u7684URL\u3002<br \/>\n\u7531\u4e8e\u672c\u6b21\u6240\u6709\u8f6f\u4ef6\u90fd\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\uff0c\u6240\u4ee5\u9ed8\u8ba4\u8bbe\u7f6e\u5373\u53ef\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># # Read metrics from one or many prometheus clients\r\n<\/span>[[<span class=\"n\">inputs<\/span>.<span class=\"n\">prometheus<\/span>]]\r\n<span class=\"c\">#   ## An array of urls to scrape metrics from.\r\n<\/span><span class=\"n\">urls<\/span> = [<span class=\"s2\">\"http:\/\/localhost:9100\/metrics\"<\/span>]\r\n<span class=\"c\">#\r\n<\/span><\/code><\/pre>\n<p>\u66f4\u6539\u8bbe\u7f6e\u540e\uff0c\u91cd\u65b0\u542f\u52a8Telegraf\u3002<\/p>\n<h3>\u786e\u5b9a<\/h3>\n<p>InfluxDB \u306e Web \u753b\u9762\u304b\u3089\u4ee5\u4e0b\u306e\u6761\u4ef6\u3067\u691c\u7d22\u3057\u3066\u3001 Prometheus \u3067\u53d6\u5f97\u3057\u305f\u60c5\u5831\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>\u6765\u6e90\uff1atest_bucket<br \/>\n\u8fc7\u6ee4\u5668\uff1a_measurement = node_cpu_seconds_total<br \/>\n\u641c\u7d22\u65f6\u95f4\u6bb5\uff1a\u8fc7\u53bb5\u5206\u949f<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"InfluxDB\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d263337434c4406c36a32\/36-0.jpeg\" alt=\"WS000705.JPG\" \/><\/div>\n<p>\u6211\u786e\u8ba4\u4e86\u60c5\u62a5\u5df2\u7ecf\u88ab\u6b63\u786e\u50a8\u5b58\u3002<\/p>\n<p>\u5982\u679c InfluxDB \u548c Grafana \u5df2\u7ecf\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7 Grafana \u786e\u8ba4\u76f8\u540c\u7684\u4fe1\u606f\u3002<br \/>\n\u70b9\u51fb\u300c\u811a\u672c\u7f16\u8f91\u5668\u300d\u6309\u94ae\uff0c\u786e\u8ba4\u67e5\u8be2\u8bed\u53e5\uff0c\u5e76\u5c06\u5176\u590d\u5236\u5230 Grafana \u7684\u7f51\u9875\u4e0a\u3002<br \/>\n\u5728 Grafana \u4e0a\uff0c\u9009\u62e9\u4e0e\u4e0a\u8ff0\u76f8\u540c\u7684\u641c\u7d22\u65f6\u95f4\u6bb5\uff0c\u9009\u62e9\u300c\u8fc7\u53bb5\u5206\u949f\u300d\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"script_editor\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d263337434c4406c36a32\/39-0.jpeg\" alt=\"WS000707.JPG\" \/><\/div>\n<pre class=\"post-pre\"><code>from(bucket: \"test_bucket\")\r\n  |&gt; range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |&gt; filter(fn: (r) =&gt; r[\"_measurement\"] == \"node_cpu_seconds_total\")\r\n  |&gt; aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |&gt; yield(name: \"mean\")\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"Grafana\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d263337434c4406c36a32\/41-0.jpeg\" alt=\"WS000708.JPG\" \/><\/div>\n<p>\u6211\u4e5f\u53ef\u4ee5\u5728Grafana\u4e0a\u786e\u8ba4\u5230\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6267\u884c\u73af\u5883\uff1a [root@testhost ~]# uname -a Linux testhost 4.18.0 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-35934","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus\uff1a\u4f7f\u7528telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230influxdb\u5e76\u5728grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\" \/>\n<meta property=\"og:description\" content=\"\u6267\u884c\u73af\u5883\uff1a [root@testhost ~]# uname -a Linux testhost 4.18.0 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus\uff1a\u4f7f\u7528telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230influxdb\u5e76\u5728grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-04T00:36:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T22:14:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d263337434c4406c36a32\/36-0.jpeg\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/\",\"name\":\"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-03-04T00:36:53+00:00\",\"dateModified\":\"2024-04-28T22:14:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus\uff1a\u4f7f\u7528telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230influxdb\u5e76\u5728grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316","og_description":"\u6267\u884c\u73af\u5883\uff1a [root@testhost ~]# uname -a Linux testhost 4.18.0 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus\uff1a\u4f7f\u7528telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230influxdb\u5e76\u5728grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-04T00:36:53+00:00","article_modified_time":"2024-04-28T22:14:53+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d263337434c4406c36a32\/36-0.jpeg"}],"author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/","name":"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-03-04T00:36:53+00:00","dateModified":"2024-04-28T22:14:53+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Prometheus\uff1a\u4f7f\u7528Telegraf\u5c06\u6570\u636e\u5b58\u50a8\u5230InfluxDB\u5e76\u5728Grafana\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/prometheus%ef%bc%9a%e4%bd%bf%e7%94%a8telegraf%e5%b0%86%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%88%b0influxdb%e5%b9%b6%e5%9c%a8grafana%e4%b8%ad%e8%bf%9b%e8%a1%8c%e5%8f%af%e8%a7%86%e5%8c%96%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/35934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=35934"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/35934\/revisions"}],"predecessor-version":[{"id":83543,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/35934\/revisions\/83543"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=35934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=35934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=35934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}