Настраиваемое отображение индекса в graylog 3 для создания нового поля геохэш - PullRequest
0 голосов
/ 21 ноября 2019

Я определил новый индекс в Graylog3 с префиксом индекса «облачного фронта». У меня есть Graylog конвейер, настроенный для получения информации о геолокации:

rule "cloudfrontGeoIP"
when 
has_field("c-ip")
then 
let geo = lookup("GeoipLookupTable",to_string($message."c-ip"));
set_field("src_ip_geolocation", geo["coordinates"]);
set_field("src_ip_geo_country_code", geo["country"].iso_code);
set_field("src_ip_geo_country_name", geo["country"].names.en);
set_field("src_ip_geo_city_name", geo["city"].names.en); 
end

Поэтому я обновляю отображение для создания нового поля src_ip_location на основе копии src_ip_geolocation:

{  
  "template": "cloudfront_*",  
  "mappings" : {
    "message" : {
      "properties" : {    
        "src_ip_geolocation": {
          "type": "text",
          "copy_to": "src_ip_location"
        },
        "src_ip_location": { 
           "type": "geo_point" 
        }        
      }
    }
  }
}
curl -X PUT -d @graylog-custom-mapping.json -H 'Content-Type: application/json' 'https://<es_url>/_template/graylog-custom-mapping?pretty'
{
  "acknowledged" : true
}

Новый шаблон успешно создан в домене Elasticsearch:

curl -XGET 'https://<es_domain>/_template/graylog-custom-mapping?pretty'

{
  "graylog-custom-mapping": {
    "order": 0,
    "index_patterns": [
      "cloudfront_*"
    ],
    "settings": {},
    "mappings": {
      "message": {
        "properties": {
          "src_ip_geolocation": {
            "type": "text",
            "copy_to": "src_ip_location"
          },
          "src_ip_location": {
            "type": "geo_point"
          }
        }
      }
    },
    "aliases": {}
  }
}

Затем я поворачиваю активный индекс, чтобы вызвать новый индекс воссоздания. Система> Индексы> |Выберите «Индекс облачного фронта» Maintenace> Повернуть индекс активной записи.

Если я проверю сейчас, свойства сообщения шаблона облачного фронта являются настройками по умолчанию, основанными на внутреннем шаблоне graylog, и пользовательские свойства не применяются:

curl -X GET 'https://<url_domain>/_template/cloudfront-template?pretty=' 

{
  "cloudfront-template": {
    "order": -1,
    "index_patterns": [
      "cloudfront_*"
    ],
    "settings": {
      "index": {
        "analysis": {
          "analyzer": {
            "analyzer_keyword": {
              "filter": "lowercase",
              "tokenizer": "keyword"
            }
          }
        }
      }
    },
    "mappings": {
      "message": {
        "properties": {
          "message": {
            "type": "text",
            "analyzer": "standard",
            "fielddata": false
          },
          "full_message": {
            "type": "text",
            "analyzer": "standard",
            "fielddata": false
          },
          "timestamp": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "gl2_receive_timestamp": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "gl2_processing_timestamp": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "source": {
            "type": "text",
            "analyzer": "analyzer_keyword",
            "fielddata": true
          },
          "streams": {
            "type": "keyword"
          }
        },
        "dynamic_templates": [
          {
            "internal_fields": {
              "match": "gl2_*",
              "match_mapping_type": "string",
              "mapping": {
                "type": "keyword"
              }
            }
          },
          {
            "store_generic": {
              "match_mapping_type": "string",
              "mapping": {
                "type": "keyword"
              }
            }
          }
        ],
        "_source": {
          "enabled": true
        }
      }
    },
    "aliases": {}
  }
}

Что не так?

Graylog 3.1.3 + ES 6.4

Спасибо

...