Hi,
I'm running 8.9. Here is the run time field I applied to the index.
put dev-xvulnerability-18-2023.09.27/_mapping
{
"properties": {
"kpi.vulnerability_age_days": {
"type": "long",
"script": {
"source": """
if (doc["vulnerability.state.keyword"].value == "remediated") {
emit((doc["vulnerability.last_assessed_for_vulnerabilities"].value.millis - doc["nexpos.vulnerability.instance.date_found"].value.millis) / 1000 / 60 / 60 / 24) }
else {
emit((new Date().getTime() - doc["nexpose.vulnerability.instance.date_found"].value.millis) / 1000 / 60 / 60 / 24) }
""",
"lang": "painless"
}
}
}
}
Screenshot of the KPI field and no field data...
KQL query....
kpi.vulnerability_age_days : *
This comes back with no results.
Here is a DSL query....
GET dev-xvulnerability-18-2023.09.27/_search
{
"_source": [
"kpi.vulnerability_age_days"],
"fields": [
"kpi.vulnerability_age_days"
]
}
Sample results....
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2747,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "dev-xvulnerability-18-2023.09.27",
"_id": "18-win2016-1-CVE-2023-29351",
"_score": 1,
"_source": {},
"fields": {
"kpi.vulnerability_age_days": [
111
]
}
},
{
"_index": "dev-xvulnerability-18-2023.09.27",
"_id": "18-win2016-1-CVE-2023-29372",
"_score": 1,
"_source": {},
"fields": {
"kpi.vulnerability_age_days": [
111
]
}
},
{
"_index": "dev-xvulnerability-18-2023.09.27",
"_id": "18-win2016-1-CVE-2023-37205",
"_score": 1,
"_source": {},
"fields": {
"kpi.vulnerability_age_days": [
87
]
}
},
If I modify my component template to put in the run time field and re-index the data, the data is usable in Kibana. It shows up in the visualizations and I can use KQL. From my limited experience with runtime fields, I was under the impression that re-indexing is not required and those fields are calculated at search.
Thank you for responding!