爱吃糖的靓仔 2020-12-24 22:03 采纳率: 50%
浏览 96
已结题

Elacksearch 生命周期 一直报错

 


# 按顺序执行即可

# 删除老的 template
DELETE _template/process_log_templat


# 创建新的lifecycle
PUT _ilm/policy/process-log-lifecycle
{
    "policy": {
        "phases": {
            "hot": {
                "min_age": "0ms",
                "actions": {
                    "rollover": {
                        "max_age": "30d",
                        "max_size": "20gb"
                    },
                    "set_priority": {
                        "priority": 100
                    }
                }
            },
            "delete": {
                "min_age": "90d",
                "actions": {
                    "delete": {}
                }
            }
        }
    }
}




# 创建新的 template
PUT _template/process-log-template
{
  "index_patterns": ["process-log-*"],
  "settings": {
    "number_of_shards": 2,
    "index.lifecycle.name": "process-log-lifecycle", 
    "index.lifecycle.rollover_alias": "process-log",
    "index" : {
            "sort.field" : "requestTime", 
            "sort.order" : "desc" 
        }
  },
  "mappings": {
    
    "properties":{
      "consumeTime": {
        "type": "long"
      },
      "insertTime": {
        "type": "long"
      },
      "ip": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "method": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "params": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "requestTime": {
        "type": "long"
      },
      "requestUri": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "responseTime": {
        "type": "long"
      },
      "result": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "serverName": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "status": {
        "type": "long"
      },
      "userAgent": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    
    }
  }
}



# 创建初始化索引
PUT process-log-000001


// 指定写索引
POST /_aliases
{
    "actions" : [
      { "add" : { "index" : "process-log-202004", "alias" : "process-log","is_write_index" : false } },
      { "add" : { "index" : "process-log-202005", "alias" : "process-log","is_write_index" : false } },
      { "add" : { "index" : "process-log-000001", "alias" : "process-log","is_write_index" : true} }
    ]
}





 

  • 写回答

12条回答 默认 最新

  • 爱吃糖的靓仔 2020-12-25 11:30
    关注

    救命呀  大佬們

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化