Skip to content

[Feature] Add kibana_spaces support to elasticstack_kibana_synthetics_monitor #3300

Description

@danpowell88

Is your feature request related to a problem? Please describe.

Synthetic monitors can only be assigned to a single Kibana space via the space_id attribute. The Kibana UI and API support sharing a monitor across multiple spaces using the spaces / kibana_spaces field (which maps to saved object initialNamespaces), but the Terraform provider doesn't expose this. This means users who need a monitor visible in multiple spaces must either duplicate the monitor or manage sharing out-of-band via API calls after terraform apply.

Describe the resource you would like to have implemented.

The Kibana Synthetics Monitor API (Add Monitor API) accepts a spaces field (array of strings) in the request body. Internally this is stored as ConfigKey.KIBANA_SPACES and sets initialNamespaces on the saved object, allowing the monitor to appear in multiple Kibana spaces without duplication.

Relevant Kibana source:

  • x-pack/solutions/observability/plugins/synthetics/server/services/monitor_config_repository.ts — uses initialNamespaces: spaces on saved object creation
  • x-pack/solutions/observability/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.ts — handles KIBANA_SPACES on update
  • A wildcard value ["*"] shares to all spaces

Describe the solution you'd like

Add an optional kibana_spaces attribute (list of strings) to elasticstack_kibana_synthetics_monitor:

resource "elasticstack_kibana_synthetics_monitor" "my_monitor" {
  name           = "My Monitor"
  space_id       = "y"
  kibana_spaces  = ["y", "infrastructure"]
  # ... other fields
}

When kibana_spaces is set, the provider should include the spaces field in the Kibana API request body. The space_id remains the "owner" space for the API endpoint path, while kibana_spaces controls visibility. A value of ["*"] should share to all spaces.

Describe alternatives you've considered

  • Duplicating monitors in each space (doubles cost, creates drift risk)
  • Using a null_resource with local-exec to call the Kibana API after monitor creation (fragile, out-of-band state)
  • Using elasticstack_kibana_import_saved_objects to copy the monitor SO to additional spaces (doesn't maintain sharing link)

Additional context

  • Provider version tested: 0.14.4
  • Latest provider version checked: 0.15.2 (still missing this field)
  • Kibana versions with this feature: 8.x+
  • The Kibana UI exposes this under "Advanced > Kibana Spaces" in the monitor edit form

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-researchQueued for research-factory: needs implementation specphase-researchtriagedIssue has been classified and routed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions