Repository navigation
Description
Describe the bug
Osquery packs assigned to an agent policy in Kibana (Osquery > Packs) are stored by Kibana in the osquery_manager package policy under inputs[].config.osquery.value.packs. elasticstack_fleet_integration_policy does not model input-level config, and when it updates the package policy it sends the inputs without that config. As a result every pack is removed from the agent policy.
Kibana still shows the pack as assigned to the policy (the pack saved object's policy_ids is unchanged), but agents no longer receive or run any scheduled pack query. Live queries keep working, so the problem is silent: scheduled results just stop.
In our case a routine terraform apply upgraded integration_version from the latest-version data source (osquery_manager 1.34.0 -> 1.35.1). The Fleet policy revision created by that update had an empty packs object. The revision before it had 4 packs.
To Reproduce
Steps to reproduce the behavior:
- TF configuration used:
data "elasticstack_fleet_integration" "osquery" {
name = "osquery_manager"
}
resource "elasticstack_fleet_integration_policy" "osquery" {
name = "example-osquery"
namespace = "default"
agent_policy_id = elasticstack_fleet_agent_policy.example.policy_id
integration_name = "osquery_manager"
integration_version = data.elasticstack_fleet_integration.osquery.version
inputs = {
"osquery_manager-osquery" = {
enabled = true
streams = {
"osquery_manager.action.responses" = { enabled = true, vars = jsonencode({}) }
"osquery_manager.result" = { enabled = true, vars = jsonencode({}) }
}
}
}
}- TF operations to execute:
terraform applyto create the integration policy.- In Kibana, create an Osquery pack and assign it to the agent policy.
GET /api/fleet/package_policies/<id>now shows the pack underinputs[0].config.osquery.value.packs. - Trigger any update of the resource, e.g. a newer
osquery_managerpackage version (or setintegration_versionexplicitly), thenterraform apply.
- See the error:
terraform applysucceeds with no error, butGET /api/fleet/package_policies/<id>now returnsinputs[0].configwithoutosquery.value.packs. Agents log noScheduled query 'pack_...'lines after the policy change, and pack results stop.
Expected behavior
Updating the integration policy keeps input-level config that Terraform does not manage, the same way Fleet's own integration upgrade in Kibana keeps the packs. Alternatively, input-level config could be exposed as an (optional/computed) attribute so it can be preserved or ignored.
Current workaround: lifecycle { ignore_changes = all } on the osquery_manager integration policy, and upgrade the integration from the Fleet UI instead of from Terraform.
Debug output
Not captured during the affected apply. Happy to reproduce with TF_LOG=trace and attach it if needed.
Screenshots
N/A
Versions (please complete the following information):
- OS: Linux
- Terraform Version: 1.5.7
- Provider version: v0.16.6
- Elasticsearch Version: 9.5.5 (Kibana 9.5.5, Elastic Agent 9.5.5, osquery_manager 1.34.0 -> 1.35.1)
Additional context
- Fleet policy revision history (
.fleet-policies) showed the packs going from 4 entries to none in exactly the revision where Terraform upgradedosquery_manager. Upgrades of the other integrations in the same apply (auditd, windows, system) had no visible side effect. - Saving the pack again in Kibana writes it back into the package policy, so the packs come back until the next Terraform update.
- Related: kibana#255381 (Kibana's own upgrade path is expected to carry packs over to the upgraded policy). Possibly related to how
internal/fleet/integration_policybuilds the update request body frominputsonly.
Activity
github-actions commentedon Nov 5, 2026
Thanks for the detailed bug report! I have added the
needs-reproductionlabel to this issue.This looks like a reproducible bug: the report includes a Terraform configuration, clear reproduction steps, and a description of the observed vs. expected behaviour (input-level
configforosquery_managerpacks being dropped on update). It has been queued for the reproducer-factory pipeline, which will attempt to confirm the behaviour and create a minimal reproduction case.If this has been misclassified or there is additional context to add, please leave a comment so a maintainer can adjust the label manually.
aydasraf commentedon Nov 5, 2026
We hit the same root cause with the Elastic APM integration, with a much louder impact than Osquery packs, so adding it here as a second reproduction.
What happened
When the APM integration is created, Kibana's APM plugin stores two API keys (owned by
kibana_system, "Source map read access" and "Agent Configuration read access") in the APM input config:We adopted our existing APM integration policy into Terraform (
elasticstack_fleet_integration_policy,apm9.4.2). The first apply sentPUT /api/fleet/package_policies/<id>(simplified format), and the resulting Fleet policy revision no longer contained either key. The input id also changed from<package-policy-id>toapm-apmserver-<package-policy-id>. APM Server then fell back to the Fleet output API key, which cannot read the APM system indices:RUM source mapping dropped from ~40% of errors mapped to 0% within the same minute as the Terraform apply, on every APM Server instance, in both of our environments. Central agent configuration is affected the same way. Nothing in the plan showed the change, and no value of
varscan bring the keys back because they live inconfig, notvars.Minimal reproduction (Kibana 9.4.2, provider 0.16.6)
inputs = { "apmserver-apm" = { enabled = true, vars = jsonencode({ host = "0.0.0.0:8200", url = "http://0.0.0.0:8200", capture_personal_data = true }) } }).GET /api/fleet/package_policies/<id>: both API keys are present ininputs[0].config["apm-server"].value.capture_personal_datatofalseand apply.GETagain: the var is updated, both API keys are gone.The same thing happens with a raw
PUT ?format=simplifiedcall, so the provider can't avoid it by changing what it sends in the simplified body. A typed (non-simplified)PUTcarryingconfigdoes keep it.I've opened #5481 with a fix: it snapshots input and stream
configvia a typed GET before the simplified update and, if the update dropped anything, writes it back with one typed update (version+inputsonly). It includes acceptance tests for both a generic out-of-bandconfigand this APM case.