elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.82k stars 8.2k forks source link

[Index Management] Index mappings details page gets broken from an unsupported data type `counted_keyword` #197592

Open ElenaStoeva opened 3 hours ago

ElenaStoeva commented 3 hours ago

How to reproduce:

  1. Create the following index with mappings in Console:
    Request to create index:
PUT test
{
  "mappings": {
    "dynamic": "true",
    "_data_stream_timestamp": {
      "enabled": true
    },
    "dynamic_templates": [
      {
        "numeric_labels": {
          "path_match": "numeric_labels.*",
          "mapping": {
            "scaling_factor": 1000000,
            "type": "scaled_float"
          }
        }
      },
      {
        "ecs_timestamp": {
          "match": "@timestamp",
          "mapping": {
            "ignore_malformed": false,
            "type": "date"
          }
        }
      },
      {
        "ecs_message_match_only_text": {
          "path_match": [
            "message",
            "*.message"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "type": "match_only_text"
          }
        }
      },
      {
        "ecs_non_indexed_keyword": {
          "path_match": "event.original",
          "mapping": {
            "doc_values": false,
            "index": false,
            "type": "keyword"
          }
        }
      },
      {
        "ecs_non_indexed_long": {
          "path_match": "*.x509.public_key_exponent",
          "mapping": {
            "doc_values": false,
            "index": false,
            "type": "long"
          }
        }
      },
      {
        "ecs_ip": {
          "path_match": [
            "ip",
            "*.ip",
            "*_ip"
          ],
          "match_mapping_type": "string",
          "mapping": {
            "type": "ip"
          }
        }
      },
      {
        "ecs_wildcard": {
          "path_match": [
            "*.io.text",
            "*.message_id",
            "*registry.data.strings",
            "*url.path"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "type": "wildcard"
          }
        }
      },
      {
        "ecs_path_match_wildcard_and_match_only_text": {
          "path_match": [
            "*.body.content",
            "*url.full",
            "*url.original"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            },
            "type": "wildcard"
          }
        }
      },
      {
        "ecs_match_wildcard_and_match_only_text": {
          "match": [
            "*command_line",
            "*stack_trace"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            },
            "type": "wildcard"
          }
        }
      },
      {
        "ecs_path_match_keyword_and_match_only_text": {
          "path_match": [
            "*.title",
            "*.executable",
            "*.name",
            "*.working_directory",
            "*.full_name",
            "*file.path",
            "*file.target_path",
            "*os.full",
            "email.subject",
            "vulnerability.description",
            "user_agent.original"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            },
            "type": "keyword"
          }
        }
      },
      {
        "ecs_date": {
          "path_match": [
            "*.timestamp",
            "*_timestamp",
            "*.not_after",
            "*.not_before",
            "*.accessed",
            "created",
            "*.created",
            "*.installed",
            "*.creation_date",
            "*.ctime",
            "*.mtime",
            "ingested",
            "*.ingested",
            "*.start",
            "*.end",
            "*.indicator.first_seen",
            "*.indicator.last_seen",
            "*.indicator.modified_at",
            "*threat.enrichments.matched.occurred"
          ],
          "unmatch_mapping_type": "object",
          "mapping": {
            "type": "date"
          }
        }
      },
      {
        "ecs_path_match_float": {
          "path_match": [
            "*.score.*",
            "*_score*"
          ],
          "path_unmatch": "*.version",
          "unmatch_mapping_type": "object",
          "mapping": {
            "type": "float"
          }
        }
      },
      {
        "ecs_usage_double_scaled_float": {
          "path_match": "*.usage",
          "match_mapping_type": [
            "double",
            "long",
            "string"
          ],
          "mapping": {
            "scaling_factor": 1000,
            "type": "scaled_float"
          }
        }
      },
      {
        "ecs_geo_point": {
          "path_match": "*.geo.location",
          "mapping": {
            "type": "geo_point"
          }
        }
      },
      {
        "ecs_flattened": {
          "path_match": [
            "*structured_data",
            "*exports",
            "*imports"
          ],
          "match_mapping_type": "object",
          "mapping": {
            "type": "flattened"
          }
        }
      },
      {
        "all_strings_to_keywords": {
          "match_mapping_type": "string",
          "mapping": {
            "ignore_above": 1024,
            "type": "keyword"
          }
        }
      }
    ],
    "properties": {
      "@timestamp": {
        "type": "date",
        "ignore_malformed": false
      },
      "agent": {
        "properties": {
          "activation_method": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ephemeral_id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "version": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "client": {
        "properties": {
          "geo": {
            "properties": {
              "city_name": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "continent_name": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "country_iso_code": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "country_name": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "location": {
                "type": "geo_point"
              },
              "region_iso_code": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "region_name": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "ip": {
            "type": "ip"
          }
        }
      },
      "cloud": {
        "properties": {
          "account": {
            "properties": {
              "id": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "availability_zone": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "instance": {
            "properties": {
              "id": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "machine": {
            "properties": {
              "type": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "origin": {
            "properties": {
              "account": {
                "properties": {
                  "id": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              },
              "provider": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "region": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "service": {
                "properties": {
                  "name": {
                    "type": "keyword",
                    "fields": {
                      "text": {
                        "type": "match_only_text"
                      }
                    }
                  }
                }
              }
            }
          },
          "provider": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "region": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "service": {
            "properties": {
              "name": {
                "type": "keyword",
                "fields": {
                  "text": {
                    "type": "match_only_text"
                  }
                }
              }
            }
          }
        }
      },
      "container": {
        "properties": {
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "data_stream": {
        "properties": {
          "dataset": {
            "type": "constant_keyword",
            "value": "apm"
          },
          "namespace": {
            "type": "constant_keyword",
            "value": "default"
          },
          "type": {
            "type": "constant_keyword",
            "value": "traces"
          }
        }
      },
      "destination": {
        "properties": {
          "address": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ip": {
            "type": "ip"
          },
          "port": {
            "type": "long"
          }
        }
      },
      "event": {
        "properties": {
          "outcome": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "success_count": {
            "type": "byte",
            "index": false
          }
        }
      },
      "faas": {
        "properties": {
          "coldstart": {
            "type": "boolean"
          },
          "execution": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "trigger": {
            "properties": {
              "request_id": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "type": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "version": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "host": {
        "properties": {
          "architecture": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "hostname": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ip": {
            "type": "ip"
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "os": {
            "properties": {
              "platform": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          }
        }
      },
      "http": {
        "properties": {
          "request": {
            "properties": {
              "body": {
                "type": "object",
                "dynamic": "false"
              },
              "cookies": {
                "type": "object",
                "dynamic": "false"
              },
              "env": {
                "properties": {
                  "REMOTE_ADDR": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "SERVER_NAME": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "SERVER_PORT": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              },
              "headers": {
                "type": "flattened"
              },
              "id": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "method": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "response": {
            "properties": {
              "decoded_body_size": {
                "type": "long",
                "index": false
              },
              "encoded_body_size": {
                "type": "long",
                "index": false
              },
              "finished": {
                "type": "boolean"
              },
              "headers": {
                "type": "flattened"
              },
              "headers_sent": {
                "type": "boolean"
              },
              "status_code": {
                "type": "long"
              },
              "transfer_size": {
                "type": "long",
                "index": false
              }
            }
          },
          "version": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "labels": {
        "properties": {
          "aws_lambda_invoked_arn": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "aws_s3_bucket": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "aws_s3_copy_source": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "aws_s3_key": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_parameter_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_parameter_sensitive": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_parameter_value": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_run_completed": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_run_description": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_run_result": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_run_url": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_run_user": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "ci_pipeline_type": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "cloud_account_id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "faas_invocation_id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "globalID": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "host_ip": {
            "type": "ip"
          },
          "host_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_computer_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_agent_label": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_plugin_name": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_plugin_version": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_pipeline_step_type": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "jenkins_url": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "owner": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "service_namespace": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "session ID": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "session lock released": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "meta": {
        "properties": {
          "message_size_bytes": {
            "type": "float"
          }
        }
      },
      "numeric_labels": {
        "properties": {
          "ci_pipeline_run_durationMillis": {
            "type": "scaled_float",
            "scaling_factor": 1000000
          },
          "ci_pipeline_run_number": {
            "type": "scaled_float",
            "scaling_factor": 1000000
          },
          "session lock attempts": {
            "type": "scaled_float",
            "scaling_factor": 1000000
          }
        }
      },
      "observer": {
        "properties": {
          "hostname": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "type": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "version": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "parent": {
        "properties": {
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "process": {
        "properties": {
          "args": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "parent": {
            "properties": {
              "pid": {
                "type": "long"
              }
            }
          },
          "pid": {
            "type": "long"
          },
          "title": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          }
        }
      },
      "processor": {
        "properties": {
          "event": {
            "type": "keyword"
          }
        }
      },
      "source": {
        "properties": {
          "ip": {
            "type": "ip"
          },
          "nat": {
            "properties": {
              "ip": {
                "type": "ip"
              }
            }
          },
          "port": {
            "type": "long"
          }
        }
      },
      "span": {
        "properties": {
          "action": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "composite": {
            "properties": {
              "compression_strategy": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "count": {
                "type": "long"
              },
              "sum": {
                "properties": {
                  "us": {
                    "type": "long"
                  }
                }
              }
            }
          },
          "db": {
            "properties": {
              "instance": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "rows_affected": {
                "type": "long"
              },
              "statement": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "type": {
                "type": "keyword",
                "ignore_above": 1024
              },
              "user": {
                "properties": {
                  "name": {
                    "type": "keyword",
                    "fields": {
                      "text": {
                        "type": "match_only_text"
                      }
                    }
                  }
                }
              }
            }
          },
          "destination": {
            "properties": {
              "service": {
                "properties": {
                  "name": {
                    "type": "keyword",
                    "fields": {
                      "text": {
                        "type": "match_only_text"
                      }
                    }
                  },
                  "resource": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "type": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              }
            }
          },
          "duration": {
            "properties": {
              "us": {
                "type": "long"
              }
            }
          },
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "kind": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "links": {
            "properties": {
              "span": {
                "properties": {
                  "id": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              },
              "trace": {
                "properties": {
                  "id": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              }
            }
          },
          "message": {
            "properties": {
              "queue": {
                "properties": {
                  "name": {
                    "type": "keyword",
                    "fields": {
                      "text": {
                        "type": "match_only_text"
                      }
                    }
                  }
                }
              }
            }
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "representative_count": {
            "type": "scaled_float",
            "index": false,
            "scaling_factor": 1000
          },
          "stacktrace": {
            "type": "object",
            "dynamic": "false"
          },
          "subtype": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "sync": {
            "type": "boolean"
          },
          "type": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "timestamp": {
        "properties": {
          "us": {
            "type": "long"
          }
        }
      },
      "trace": {
        "properties": {
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "transaction": {
        "properties": {
          "custom": {
            "type": "object",
            "dynamic": "false"
          },
          "duration": {
            "properties": {
              "us": {
                "type": "long"
              }
            }
          },
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "message": {
            "properties": {
              "age": {
                "properties": {
                  "ms": {
                    "type": "long"
                  }
                }
              },
              "headers": {
                "properties": {
                  "Contenttype": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Elastic-Apm-Traceparent": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Event_type": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Id": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jms_sqsmessagetype": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jmsexpiration": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jmsmessageid": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jmstimestamp": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jmsxdeliverycount": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Jmsxgroupid": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Routing_notification_type": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Timestamp": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Traceparent": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Tracestate": {
                    "type": "keyword",
                    "ignore_above": 1024
                  },
                  "Work_resource_type": {
                    "type": "keyword",
                    "ignore_above": 1024
                  }
                }
              },
              "queue": {
                "properties": {
                  "name": {
                    "type": "keyword",
                    "fields": {
                      "text": {
                        "type": "match_only_text"
                      }
                    }
                  }
                }
              }
            }
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "profiler_stack_trace_ids": {
            "type": "counted_keyword"
          },
          "representative_count": {
            "type": "scaled_float",
            "index": false,
            "scaling_factor": 1000
          },
          "result": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "sampled": {
            "type": "boolean"
          },
          "span_count": {
            "properties": {
              "dropped": {
                "type": "long"
              },
              "started": {
                "type": "long"
              }
            }
          },
          "type": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "url": {
        "properties": {
          "domain": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "full": {
            "type": "wildcard",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "original": {
            "type": "wildcard",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "path": {
            "type": "wildcard"
          },
          "port": {
            "type": "long"
          },
          "query": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "scheme": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      },
      "user": {
        "properties": {
          "id": {
            "type": "keyword",
            "ignore_above": 1024
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          }
        }
      },
      "user_agent": {
        "properties": {
          "device": {
            "properties": {
              "name": {
                "type": "keyword",
                "fields": {
                  "text": {
                    "type": "match_only_text"
                  }
                }
              }
            }
          },
          "name": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "original": {
            "type": "keyword",
            "fields": {
              "text": {
                "type": "match_only_text"
              }
            }
          },
          "os": {
            "properties": {
              "full": {
                "type": "keyword",
                "fields": {
                  "text": {
                    "type": "match_only_text"
                  }
                }
              },
              "name": {
                "type": "keyword",
                "fields": {
                  "text": {
                    "type": "match_only_text"
                  }
                }
              },
              "version": {
                "type": "keyword",
                "ignore_above": 1024
              }
            }
          },
          "version": {
            "type": "keyword",
            "ignore_above": 1024
          }
        }
      }
    }
  }
}

  1. Go to Index management and click on the created index
  2. Click on the Mappings tab. It shows an error:

Image

Error in console:

Uncaught TypeError: Cannot read properties of undefined (reading 'label')
    at use_state_listener.tsx:30:1
    at Array.map (<anonymous>)
    at use_state_listener.tsx:28:1
    at mountMemo (react-dom.development.js:15846:1)
    at Object.useMemo (react-dom.development.js:16219:1)
    at useMemo (react.development.js:1532:1)
    at useMappingsStateListener (use_state_listener.tsx:26:1)
    at DetailsPageMappingsContent (details_page_mappings_content.tsx:155:1)
    at renderWithHooks (react-dom.development.js:14985:1)
    at mountIndeterminateComponent (react-dom.development.js:17811:1)

This error seems to come from this line: https://github.com/elastic/kibana/blob/1c3705ba5b5aa60ea451a7d0ff7f95f2d21a1b80/x-pack/plugins/index_management/public/application/components/mappings_editor/use_state_listener.tsx#L59

It probably fails because of an unsupported data type. I looked through the mappings and noticed one mapping with type counted_keyword which is not in the supported ones:

"profiler_stack_trace_ids": {
    "type": "counted_keyword"
},

To see if this is the cause, I created a new index with the same mappings but removed this specific one. Then verified that the Mappings details page loads and works as expected.

elasticmachine commented 3 hours ago

Pinging @elastic/kibana-management (Team:Kibana Management)