Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elastic_agent - Set specific object_type_mapping_type #7179

Conversation

andrewkroh
Copy link
Member

@andrewkroh andrewkroh commented Jul 28, 2023

What does this PR do?

Avoid wildcard value for object_type_mapping_type so that objects are not matched. The problem was that filebeat_input.httpjson_interval_pages_total, which holds an object, was being matched by the dynamic mapping specified for filebeat_input.*_total.

Fixes elastic/beats#35933

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Mappings

metrics-elastic_agent.filebeat_input@package
{
  "dynamic": true,
  "dynamic_templates": [
    {
      "container.labels": {
        "path_match": "container.labels.*",
        "mapping": {
          "type": "keyword"
        },
        "match_mapping_type": "string"
      }
    },
    {
      "filebeat_input.*.histogram.count": {
        "path_match": "filebeat_input.*.histogram.count",
        "mapping": {
          "type": "long"
        },
        "match_mapping_type": "*"
      }
    },
    {
      "filebeat_input.*.histogram.*": {
        "path_match": "filebeat_input.*.histogram.*",
        "mapping": {
          "type": "double"
        },
        "match_mapping_type": "*"
      }
    },
    {
      "filebeat_input.*_total": {
        "path_match": "filebeat_input.*_total",
        "mapping": {
          "type": "long"
        },
        "match_mapping_type": "long"
      }
    },
    {
      "filebeat_input.*_gauge": {
        "path_match": "filebeat_input.*_gauge",
        "mapping": {
          "type": "long"
        },
        "match_mapping_type": "long"
      }
    },
    {
      "filebeat_input.*_length": {
        "path_match": "filebeat_input.*_length",
        "mapping": {
          "type": "long"
        },
        "match_mapping_type": "long"
      }
    }
  ],
  "properties": {
    "cloud": {
      "properties": {
        "availability_zone": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "image": {
          "properties": {
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "instance": {
          "properties": {
            "name": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "provider": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "machine": {
          "properties": {
            "type": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "project": {
          "properties": {
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "region": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "account": {
          "properties": {
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        }
      }
    },
    "container": {
      "properties": {
        "image": {
          "properties": {
            "name": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "name": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "id": {
          "ignore_above": 1024,
          "type": "keyword"
        }
      }
    },
    "agent": {
      "properties": {
        "build": {
          "properties": {
            "original": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "name": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "id": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "ephemeral_id": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "type": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "version": {
          "ignore_above": 1024,
          "type": "keyword"
        }
      }
    },
    "@timestamp": {
      "ignore_malformed": false,
      "type": "date"
    },
    "ecs": {
      "properties": {
        "version": {
          "ignore_above": 1024,
          "type": "keyword"
        }
      }
    },
    "log": {
      "properties": {
        "level": {
          "ignore_above": 1024,
          "type": "keyword"
        }
      }
    },
    "data_stream": {
      "properties": {
        "namespace": {
          "type": "constant_keyword"
        },
        "type": {
          "type": "constant_keyword"
        },
        "dataset": {
          "type": "constant_keyword"
        }
      }
    },
    "host": {
      "properties": {
        "hostname": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "os": {
          "properties": {
            "build": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "kernel": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "codename": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "name": {
              "ignore_above": 1024,
              "type": "keyword",
              "fields": {
                "text": {
                  "type": "text"
                }
              }
            },
            "family": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "version": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "platform": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "domain": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "ip": {
          "type": "ip"
        },
        "containerized": {
          "type": "boolean"
        },
        "name": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "id": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "type": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "mac": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "architecture": {
          "ignore_above": 1024,
          "type": "keyword"
        }
      }
    },
    "filebeat_input": {
      "properties": {
        "input": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "resource": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "id": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "bind_address": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "device": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "cel_executions": {
          "type": "long"
        },
        "system_packet_drops": {
          "type": "long"
        }
      }
    }
  }
}

Screenshot

Proof that httpjson metrics can now be written to Elasticsearch.

Screenshot 2023-07-28 at 09 58 43

Avoid wildcard value for `object_type_mapping_type` so that objects are not
matched. The problem was that `filebeat_input.httpjson_interval_pages_total`,
which holds an object, was being matched by the dynamic mapping specified for
`filebeat_input.*_total`. This made it a long which led to a mapping exception.

Fixes elastic/beats#35933
@andrewkroh andrewkroh force-pushed the elastic_agent/bugfix/fb-input-histogram-type-match branch from 21a0c91 to 3dee69a Compare July 28, 2023 13:53
@elasticmachine
Copy link

elasticmachine commented Jul 28, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-07-28T14:11:34.409+0000

  • Duration: 15 min 34 sec

Test stats 🧪

Test Results
Failed 0
Passed 37
Skipped 0
Total 37

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

elasticmachine commented Jul 28, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (0/0) 💚
Files 100.0% (0/0) 💚
Classes 100.0% (0/0) 💚
Methods 33.333% (25/75) 👎 -63.116
Lines 100.0% (0/0) 💚 7.945
Conditionals 100.0% (0/0) 💚

@andrewkroh andrewkroh marked this pull request as ready for review July 28, 2023 13:55
@andrewkroh andrewkroh requested a review from a team as a code owner July 28, 2023 13:55
@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

Copy link
Contributor

@ShourieG ShourieG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@pierrehilbert pierrehilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewkroh andrewkroh merged commit 56b0935 into elastic:main Jul 28, 2023
4 checks passed
@elasticmachine
Copy link

Package elastic_agent - 1.9.1 containing this change is available at https://epr.elastic.co/search?package=elastic_agent

gizas pushed a commit that referenced this pull request Sep 5, 2023
Avoid wildcard value for `object_type_mapping_type` so that objects are not
matched. The problem was that `filebeat_input.httpjson_interval_pages_total`,
which holds an object, was being matched by the dynamic mapping specified for
`filebeat_input.*_total`. This made it a long which led to a mapping exception.

Fixes elastic/beats#35933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Integration:Elastic-Agent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[filebeat][httpjson] filebeat_input.httpjson_interval_pages_total field causing parsing exception
5 participants