Exemple #1
0
  def __init__(self):
    geo_ip_operation = get_operator("geo_ip").get_default_operation()

    geo_ip_operation['settings']["/country/names/en"] = True
    geo_ip_operation['settings']["/city/names/en"] = True
    geo_ip_operation['settings']["/location/latitude"] = True
    geo_ip_operation['settings']["/location/longitude"] = True

    geo_ip_operation['fields'] += [
      Field("country", "string").to_dict(),
      Field("city", "string").to_dict(),
      Field("latitude", "double").to_dict(),
      Field("longitude", "double").to_dict()
    ]

    self._fields = [
      Field("date", "date"),
      Field("component", "string"),
      Field("log_level", "string"),
      Field("details", "string"),
      Field("message", "text_en"),
      Field("ip", "string", [geo_ip_operation]),
      Field("user", "string"),
      Field("http_method", "string"),
      Field("path", "string"),
      Field("protocol", "string")
    ]
  def test_generate_geo_ip_morphline(self):
    geo_ip_dict = get_operator('geo_ip').get_default_operation()

    geo_ip_dict['fields'] = [
        Field("test_field_1", "string").to_dict(),
        Field("test_field_2", "string").to_dict()
      ]

    _test_generate_field_operation_morphline(geo_ip_dict)
  def test_generate_extract_uri_components_operation_morphline(self):
    extract_uri_dict = get_operator('extract_uri_components').get_default_operation()

    extract_uri_dict['fields'] = [
        Field("test_field_1", "string").to_dict(),
        Field("test_field_2", "string").to_dict()
      ]

    _test_generate_field_operation_morphline(extract_uri_dict)
  def test_generate_split_operation_morphline(self):
    split_dict = get_operator('split').get_default_operation()

    split_dict['fields'] = [
        Field("test_field_1", "string").to_dict(),
        Field("test_field_2", "string").to_dict()
      ]

    _test_generate_field_operation_morphline(split_dict)
  def test_generate_translate_morphline(self):
    translate_dict = get_operator('translate').get_default_operation()

    translate_dict['fields'] = [
      Field("test_field_1", "string").to_dict(),
      Field("test_field_2", "string").to_dict()
    ]

    translate_dict['settings']['mapping'].append({"key":"key","value":"value"})

    _test_generate_field_operation_morphline(translate_dict)
  def test_generate_find_replace_morphline(self):
    find_replace_dict = get_operator('find_replace').get_default_operation()

    _test_generate_field_operation_morphline(find_replace_dict)
  def test_generate_convert_date_morphline(self):
    convert_date_dict = get_operator('convert_date').get_default_operation()

    _test_generate_field_operation_morphline(convert_date_dict)