Skip to content

Latest commit

 

History

History
191 lines (163 loc) · 11.6 KB

aws_elastic_search.md

File metadata and controls

191 lines (163 loc) · 11.6 KB

List ELK information

使用 AWS Elasticsearch Service

aws es create-elasticsearch-domain --domain-name bruce --elasticsearch-version 7.1 --elasticsearch-cluster-config InstanceType=t2.small.elasticsearch,InstanceCount=1 --ebs-options EBSEnabled=true,VolumeType=standard,VolumeSize=10 --access-policies '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"*"},"Action":["es:*"],"Condition":{"IpAddress":{"aws:SourceIp":["60.251.40.253","118.163.170.73","35.165.85.252"]}}}]}'
* 查詢 es domain command
aws es describe-elasticsearch-domain --domain bruce

將 cloudwatch 資料,餵到 ES 的設定

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "es:*"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:es:region:account-id:domain/target-domain-name/*"
        }
    ]
}

將 serverless log (lambda 資料) 寫入到 elastic search 中

取得 cloudwatch 的資料

Query String

kibana 說明文件

insert elasticSearch index

Amazon Elasticsearch Service Slow Logs

ELK course

將 mysql 轉換成 json

$ sudo yum install mysql-devel
$ sudo yum list | grep python3 | grep dev
$ sudo yum install python36-devel
* example
$ mysql-to-json -e 'SELECT * FROM information_schema.tables' > tables.json

建立 date format 的方式

  • 先建立 index, then 再用 mapping 的方式,先設定好 date format
  • 範例
# 建立 index
PUT /odc

# 設定 index mapping
PUT /odc/_mapping
{
    "properties": {
      "updated_at": {
        "type":   "date",
        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
      },
      "created_at": {
        "type":   "date",
        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
      }
    }
}

用 logstash 傳資料到,在 AWS ES 上

$ logstash-plugin install logstash-output-amazon_es

關於 index 操作的一些文件

一些常用到的 kibana console command

  • query index
GET /_cat/indices?v
  • 取得 index 資料
GET /index
GET /odc
  • 取得 index stats
GET /_stats

geographical location

使用 serverless 將資料放到 ES 中

在 AWS EC2 上安裝 docker - 目前改用 AWS 的 elasticsearch service 來玩

收集 AWS 使用資料

收集 MySQL 資料

收集 lambda 資料

中文說明

public cloud 的比較

將資料 feed 到 elastic search 的方式

log

monitoring

reference