基于Metricbeat+Elasticsearch+Kibana+Grafana搭建运维主机管理系统


声明:本文转载自https://my.oschina.net/majiajue/blog/1615910,转载目的在于传递更多信息,仅供学习交流之用。如有侵权行为,请联系我,我会及时删除。

  • 1.组件介绍:

  • Beats(version:6.1.2):数据采集的得力工具。将这些采集器安装在您的服务器中,它们就会把数据汇总到 Elasticsearch。如果需要更加强大的处理性能,Beats 还能将数据输送到 Logstash 进行转换和解析。
    
  • ElasticSearch(version:6.1.2):一个分布式的 RESTful风格的搜索和数据分析引擎,能够解决不断涌现出的各种用例
    
  • kibana(version:6.1.2):能够以图表的形式呈现数据,并且具有可扩展的用户界面
    
  • Grafana:是一个开源指标分析和可视化套件。 它最常用于可视化基础设施和应用程序分析的时间序列数据,但许多应用于其他领域,包括工业传感器,家庭自动化,天气和过程控制.
    
  • 2.本文的ElasticSearch、Beats、kibana和Grfana全部基于Ubunutu 16.04 Server操作系统安装,其他操作系统参考官网文档地址为:https://www.elastic.co/cn/products 点击下载可以看到elasticsearch,beats和kibana的下载安装步骤介绍。

  • 3.安装elasticsearch:

  • 3.1. 登录操作系统,安装公共签名钥匙:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add

操作如下图: image.png

  • 3.2 把elasticsearch的安装源写入到ubunutu的安装源中:
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list

  • 3.3 执行安装命令:
sudo apt-get update && sudo apt-get install elasticsearch

命令执行完以后我们增加到开机启动,命令如下:

update-rc.d elasticsearch defaults 95 10
  • 3.4 修改配置文件: elasticsearch的配置文件目录在/etc/elasticsearch/下,分别有三个截图如下: image.png 重点修改第一个elasticsearch.yml,执行命令
vi elasticsearch.yml

打开配置文件以后我们这里提供单机配置,集群的后面在考虑,所以下面的elasticsearch配置文件均为单机配置,修改配置文件中的network.host 以及port就好其余保持默认,修改完成后的配置文件如下:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#修改为主机的IP地址
network.host: 192.168.20.142
#
# Set a custom port for HTTP:
#
#修改你想要的端口我这里保持的默认
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

最后执行命令启动: ··· service elasticsearch start ···

启动后访问http://你配置的IP:配置的端口访问,我的就是http://192.168.20.142:9000 界面如下图所示表示访问成功:

image.png

  • 4 安装Beats 安装源前面在安装elasticsearch的时候已经配置过了所以这里直接运行命令即可
apt-get install metricbeat

安装完成后,加入开机启动项:

update-rc.d metricbeat defaults 95 10

修改配置文件,配置目录在/etc/metricbeat/,文件目录如下: image.png 重点修改metricbeat.yml其他保持默认,有兴趣的可以继续研究,就是插件的目录,编辑这个yml文件:

vi metricbeat.yml

我的配置文件如下:

###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common
# options. The metricbeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/metricbeat/index.html

#==========================  Modules configuration ============================

metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
  #_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "192.168.20.142:5601"

#============================= Elastic Cloud ==================================

# These settings simplify using metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.20.142:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"

#----------------------------- Logstash output --------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

# Sets log level. The default log level is info.
# Available log levels are: critical, error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]
                              

修改其中的setup.kiabana:host 以及 output.elasticsearch:hosts,其中setup.kiabana:host 的地址改为后面要安装的kibana的地址我这里是192.168.20.142:5601 这里修改为你的就好,output.elasticsearch:hosts就是上面安装的elasticsearch的地址192.168.20.142:9000 安装完成后先不慌启动因为kibana还没安装。

  • 5 安装kibana 执行安装命令:
 apt-get install kibana

安装完成后加入先加入开机启动项:

update-rc.d kibana defaults 95 10

修改配置文件,配置文件目录在/etc/kibana,如下图所示: image.png

编辑配置文件:

vi kibana.yml

修改配置文件中的server.port、server.host和 elasticsearch.url 其中server.port 对应上面metricbeat的端口就好保持默认,然后server.host配置为ip方便其他机器安装metricbeat能直接访问,elasticsearch.url直接配置第一步配置的端口和ip即可,我的配置文件如下:

# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.20.142"

# Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects
# the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests
# to Kibana. This setting cannot end in a slash.
#server.basePath: ""

# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576

# The Kibana server's name.  This is used for display purposes.
#server.name: "your-hostname"

# The URL of the Elasticsearch instance to use for all your queries.

elasticsearch.url: "http://192.168.20.142:9200"

# When this setting's value is true Kibana uses the hostname specified in the server.host
# setting. When the value of this setting is false, Kibana uses the hostname of the host
# that connects to this Kibana instance.
#elasticsearch.preserveHost: true

# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"

# The default application to load.
#kibana.defaultAppId: "home"

# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
# is proxied through the Kibana server.
#elasticsearch.username: "user"
#elasticsearch.password: "pass"

# Enables SSL and paths to the PEM-format SSL certificate and SSL key files, respectively.
# These settings enable SSL for outgoing requests from the Kibana server to the browser.
#server.ssl.enabled: false
#server.ssl.certificate: /path/to/your/server.crt
#server.ssl.key: /path/to/your/server.key

# Optional settings that provide the paths to the PEM-format SSL certificate and key files.
# These files validate that your Elasticsearch backend uses the same key files.
#elasticsearch.ssl.certificate: /path/to/your/client.crt
#elasticsearch.ssl.key: /path/to/your/client.key

# Optional setting that enables you to specify a path to the PEM file for the certificate
# authority for your Elasticsearch instance.
#elasticsearch.ssl.certificateAuthorities: [ "/path/to/your/CA.pem" ]

# To disregard the validity of SSL certificates, change this setting's value to 'none'.
#elasticsearch.ssl.verificationMode: full

# Time in milliseconds to wait for Elasticsearch to respond to pings. Defaults to the value of
# the elasticsearch.requestTimeout setting.
#elasticsearch.pingTimeout: 1500

# Time in milliseconds to wait for responses from the back end or Elasticsearch. This value
# must be a positive integer.
#elasticsearch.requestTimeout: 30000

配置改完以后 启动kibana 执行命令

service kibana start

然后在启动metricbeat

service metricbeat start

启动完成后浏览器访问: http://kibana的ip:5601,第一次打开后让你配置elasticsearch的界面如下: image.png 红框中的index pattern 填写为:metricbeat-6.1.2-* 然后点击下一步,如果成功了出现下面这图: image.png 然后打开kibana首页出现下面这个图: image.png 到此为止我们的elasticsearch+kibana+metricbeat配置成功

  • 6 安装配置Grafana 编辑ubunutu的安装源 ··· vi /etc/apt/sources.list ··· 在里面新增一行:
deb https://packagecloud.io/grafana/stable/debian/ jessie main

新增完成后保存文件执行命令:

curl https://packagecloud.io/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana

安装完成后添加开机启动项:

sudo update-rc.d grafana-server defaults

修改配置文件。grafana配置文件目录/etc/grafana 编辑配置文件命令如下:

vi /etc/grafana/grafana.ini 

修改其中的http_addr为主机IP地址 端口保持默认的3000,root_url 为http://主机IP地址:端口,如下图: image.png 修改完成后保存,启动grafana,命令如下:

sudo service grafana-server start

启动完成后浏览器访问:http://主机ip地址:3000 截图如下: image.png 默认用户名和密码是admin 输入以后登录成功跳转 image.png 点击创建datasource也是就是第二个图标create your first datasource 填入信息如下图所示: image.png pattern选择为Daily这样就选择为当年最新的索引匹配天的索引数据,填写完成后点击Save & Test 按钮 只要索引和elasearch地址配置正确会出现successful的 然后会回到上一个图点击 image.png

标红地方 出现下图: image.png 点击import Dashboard 导入我的json即可,我的json如下:

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "hideControls": false,
  "id": 5,
  "links": [],
  "refresh": false,
  "rows": [
    {
      "collapse": false,
      "height": 304,
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "监控运维",
          "fill": 3,
          "id": 1,
          "legend": {
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": true,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "span": 3,
          "stack": true,
          "steppedLine": false,
          "targets": [
            {
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.cpu.system.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            },
            {
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.cpu.user.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "B",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "CPU",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "percentunit",
              "label": null,
              "logBase": 1,
              "max": "100",
              "min": "0",
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "监控运维",
          "fill": 3,
          "id": 2,
          "legend": {
            "avg": false,
            "current": true,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": true
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "span": 3,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "总内存",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.memory.total",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            },
            {
              "alias": "已经使用",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.memory.used.bytes",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "B",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "内存",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": null,
              "format": "decbytes",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": "0",
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        },
        {
          "cacheTimeout": null,
          "colorBackground": false,
          "colorValue": true,
          "colors": [
            "#299c46",
            "rgba(237, 129, 40, 0.89)",
            "#d44a3a"
          ],
          "datasource": "监控运维",
          "decimals": 2,
          "format": "percentunit",
          "gauge": {
            "maxValue": 1,
            "minValue": 0,
            "show": true,
            "thresholdLabels": false,
            "thresholdMarkers": true
          },
          "id": 3,
          "interval": null,
          "links": [],
          "mappingType": 1,
          "mappingTypes": [
            {
              "name": "value to text",
              "value": 1
            },
            {
              "name": "range to text",
              "value": 2
            }
          ],
          "maxDataPoints": 100,
          "nullPointMode": "connected",
          "nullText": null,
          "postfix": "",
          "postfixFontSize": "50%",
          "prefix": "",
          "prefixFontSize": "50%",
          "rangeMaps": [
            {
              "from": "null",
              "text": "N/A",
              "to": "null"
            }
          ],
          "span": 2,
          "sparkline": {
            "fillColor": "rgba(31, 118, 189, 0.18)",
            "full": false,
            "lineColor": "rgb(31, 120, 193)",
            "show": false
          },
          "tableColumn": "",
          "targets": [
            {
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.cpu.user.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": "0.8,0.9,1",
          "title": "CPU",
          "type": "singlestat",
          "valueFontSize": "80%",
          "valueMaps": [
            {
              "op": "=",
              "text": "N/A",
              "value": "null"
            }
          ],
          "valueName": "current"
        },
        {
          "cacheTimeout": null,
          "colorBackground": false,
          "colorValue": true,
          "colors": [
            "#299c46",
            "rgba(237, 129, 40, 0.89)",
            "#d44a3a"
          ],
          "datasource": "监控运维",
          "decimals": 2,
          "format": "percentunit",
          "gauge": {
            "maxValue": 1,
            "minValue": 0,
            "show": true,
            "thresholdLabels": false,
            "thresholdMarkers": true
          },
          "id": 4,
          "interval": null,
          "links": [],
          "mappingType": 1,
          "mappingTypes": [
            {
              "name": "value to text",
              "value": 1
            },
            {
              "name": "range to text",
              "value": 2
            }
          ],
          "maxDataPoints": 100,
          "nullPointMode": "connected",
          "nullText": null,
          "postfix": "",
          "postfixFontSize": "50%",
          "prefix": "",
          "prefixFontSize": "50%",
          "rangeMaps": [
            {
              "from": "null",
              "text": "N/A",
              "to": "null"
            }
          ],
          "span": 2,
          "sparkline": {
            "fillColor": "rgba(31, 118, 189, 0.18)",
            "full": false,
            "lineColor": "rgb(31, 120, 193)",
            "show": false
          },
          "tableColumn": "",
          "targets": [
            {
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.memory.used.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": "0.70,0.8,0.9",
          "title": "内存使用量",
          "type": "singlestat",
          "valueFontSize": "80%",
          "valueMaps": [
            {
              "op": "=",
              "text": "N/A",
              "value": "null"
            }
          ],
          "valueName": "current"
        },
        {
          "cacheTimeout": null,
          "colorBackground": false,
          "colorValue": true,
          "colors": [
            "#299c46",
            "rgba(237, 129, 40, 0.89)",
            "#d44a3a"
          ],
          "datasource": "监控运维",
          "decimals": 2,
          "format": "percentunit",
          "gauge": {
            "maxValue": 1,
            "minValue": 0,
            "show": true,
            "thresholdLabels": false,
            "thresholdMarkers": true
          },
          "id": 5,
          "interval": null,
          "links": [],
          "mappingType": 1,
          "mappingTypes": [
            {
              "name": "value to text",
              "value": 1
            },
            {
              "name": "range to text",
              "value": 2
            }
          ],
          "maxDataPoints": 100,
          "nullPointMode": "connected",
          "nullText": null,
          "postfix": "",
          "postfixFontSize": "50%",
          "prefix": "",
          "prefixFontSize": "50%",
          "rangeMaps": [
            {
              "from": "null",
              "text": "N/A",
              "to": "null"
            }
          ],
          "span": 2,
          "sparkline": {
            "fillColor": "rgba(31, 118, 189, 0.18)",
            "full": false,
            "lineColor": "rgb(31, 120, 193)",
            "show": false
          },
          "tableColumn": "",
          "targets": [
            {
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.filesystem.used.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": "0.8,0.9,1",
          "title": "硬盘使用量",
          "type": "singlestat",
          "valueFontSize": "80%",
          "valueMaps": [
            {
              "op": "=",
              "text": "N/A",
              "value": "null"
            }
          ],
          "valueName": "current"
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    },
    {
      "collapse": false,
      "height": 250,
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "监控运维",
          "fill": 3,
          "id": 6,
          "legend": {
            "alignAsTable": false,
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "Average system.network.out.bytes"
            }
          ],
          "spaceLength": 10,
          "span": 12,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "network in",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.network.in.bytes",
                  "hide": true,
                  "id": "1",
                  "meta": {},
                  "pipelineAgg": "select metric",
                  "settings": {},
                  "type": "avg"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "beat.hostname:$Node AND !system.network.name:\"IBM USB Remote NDIS Network Device\"",
              "refId": "A",
              "timeField": "@timestamp"
            },
            {
              "alias": "network out",
              "bucketAggs": [
                {
                  "field": "@timestamp",
                  "id": "2",
                  "settings": {
                    "interval": "auto",
                    "min_doc_count": 0,
                    "trimEdges": 0
                  },
                  "type": "date_histogram"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.network.out.bytes",
                  "hide": true,
                  "id": "1",
                  "meta": {},
                  "pipelineAgg": "select metric",
                  "settings": {},
                  "type": "avg"
                },
                {
                  "field": "1",
                  "id": "3",
                  "meta": {},
                  "pipelineAgg": "1",
                  "settings": {},
                  "type": "derivative"
                }
              ],
              "query": "beat.hostname:$Node AND !system.network.name:\"IBM USB Remote NDIS Network Device\"",
              "refId": "B",
              "timeField": "@timestamp"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "网络 In / Out",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "Bps",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": "0",
              "show": true
            },
            {
              "format": "Bps",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": "0",
              "show": true
            }
          ]
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    },
    {
      "collapse": false,
      "height": 250,
      "panels": [
        {
          "columns": [],
          "datasource": "监控运维",
          "fontSize": "100%",
          "id": 7,
          "links": [],
          "pageSize": 20,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": null,
            "desc": false
          },
          "span": 12,
          "styles": [
            {
              "alias": "系统进程列表",
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "pattern": "system.process.name",
              "preserveFormat": false,
              "sanitize": false,
              "type": "string"
            },
            {
              "alias": "系统CPU资源占用",
              "colorMode": "value",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "#1f78c1",
                "rgba(245, 54, 54, 0.9)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Max system.process.cpu.total.pct",
              "thresholds": [
                "82",
                "90",
                "100"
              ],
              "type": "number",
              "unit": "percent"
            },
            {
              "alias": "内存占用",
              "colorMode": null,
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Max system.process.memory.size",
              "thresholds": [
                ""
              ],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "常驻内存",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Max system.process.memory.rss.bytes",
              "thresholds": [],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "共享内存",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Max system.process.memory.share",
              "thresholds": [],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "decimals": 2,
              "pattern": "/.*/",
              "thresholds": [],
              "type": "number",
              "unit": "short"
            }
          ],
          "targets": [
            {
              "bucketAggs": [
                {
                  "field": "system.process.name",
                  "id": "2",
                  "settings": {
                    "min_doc_count": 1,
                    "order": "desc",
                    "orderBy": "1",
                    "size": "10"
                  },
                  "type": "terms"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.process.cpu.total.pct",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "system.process.memory.size",
                  "id": "3",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "system.process.memory.rss.bytes",
                  "id": "4",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                },
                {
                  "field": "system.process.memory.share",
                  "id": "5",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            }
          ],
          "title": "系统进程",
          "transform": "table",
          "type": "table"
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    },
    {
      "collapse": false,
      "height": 250,
      "panels": [
        {
          "columns": [],
          "datasource": "监控运维",
          "fontSize": "100%",
          "id": 8,
          "links": [],
          "pageSize": null,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 1,
            "desc": true
          },
          "span": 12,
          "styles": [
            {
              "alias": "挂载分区",
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "pattern": "system.filesystem.mount_point",
              "type": "string"
            },
            {
              "alias": "剩余空间",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "system.filesystem.available",
              "thresholds": [],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "使用空间",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "system.filesystem.used.bytes",
              "thresholds": [],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "总共使用空间",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Max",
              "thresholds": [],
              "type": "number",
              "unit": "decbytes"
            },
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "decimals": 2,
              "pattern": "/.*/",
              "thresholds": [],
              "type": "number",
              "unit": "short"
            }
          ],
          "targets": [
            {
              "bucketAggs": [
                {
                  "fake": true,
                  "field": "system.filesystem.mount_point",
                  "id": "3",
                  "settings": {
                    "min_doc_count": 1,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "5"
                  },
                  "type": "terms"
                },
                {
                  "fake": true,
                  "field": "system.filesystem.available",
                  "id": "4",
                  "settings": {
                    "min_doc_count": 1,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "1"
                  },
                  "type": "terms"
                },
                {
                  "field": "system.filesystem.used.bytes",
                  "id": "2",
                  "settings": {
                    "min_doc_count": 1,
                    "order": "desc",
                    "orderBy": "_term",
                    "size": "1"
                  },
                  "type": "terms"
                }
              ],
              "dsType": "elasticsearch",
              "metrics": [
                {
                  "field": "system.filesystem.total",
                  "id": "1",
                  "meta": {},
                  "settings": {},
                  "type": "max"
                }
              ],
              "query": "beat.hostname:$Node",
              "refId": "A",
              "timeField": "@timestamp"
            }
          ],
          "title": "硬盘",
          "transform": "table",
          "type": "table"
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Dashboard Row",
      "titleSize": "h6"
    }
  ],
  "schemaVersion": 14,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "text": "elastic",
          "value": "elastic"
        },
        "datasource": "监控运维",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Node",
        "options": [],
        "query": "{\"find\": \"terms\", \"field\": \"beat.hostname\"}",
        "refresh": 1,
        "regex": "",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "2018-01-26T05:47:13.321Z",
    "to": "2018-01-26T08:27:13.321Z"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "Datababy",
  "version": 4
}

image.png 在红框中导入json点击load出现下面的图即表示成功了: image.png 还可以点击左上角的node切换不同的服务器,这样简单的运维主机管理就可以跑起来了,还可以设置哪些值超过多少发邮件报警,这些自己可以研究,我这只是抛砖哈哈 如何分享把我的dashboard分享到grafana等我后面研究研究,再来补充!

本文发表于2018年01月31日 12:19
(c)注:本文转载自https://my.oschina.net/majiajue/blog/1615910,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除.

阅读 13831 讨论 132 喜欢 2

抢先体验

扫码体验
趣味小程序
文字表情生成器

闪念胶囊

你要过得好哇,这样我才能恨你啊,你要是过得不好,我都不知道该恨你还是拥抱你啊。

直抵黄龙府,与诸君痛饮尔。

那时陪伴我的人啊,你们如今在何方。

不出意外的话,我们再也不会见了,祝你前程似锦。

这世界真好,吃野东西也要留出这条命来看看

快捷链接
网站地图
提交友链
Copyright © 2016 - 2021 Cion.
All Rights Reserved.
京ICP备2021004668号-1