feat: add labels field to kibana synthetics monitor resource #1360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: Add Labels Field to Kibana Synthetics Monitor Resource
Summary
This PR adds support for the
labels
field to the Kibana synthetics monitor terraform resource, allowing users to associate key-value pairs with monitors for filtering and grouping purposes.Changes Made
API Layer Updates
libs/go-kibana-rest/kbapi/api.kibana_synthetics.go
Labels map[string]string
field toSyntheticsMonitorConfig
struct with JSON tag"labels,omitempty"
Labels map[string]string
field toSyntheticsMonitor
struct with JSON tag"labels,omitempty"
Terraform Schema Updates
internal/kibana/synthetics/schema.go
Labels types.Map
field totfModelV0
struct with tfsdk tag"labels"
schema.MapAttribute
withtypes.StringType
elements tomonitorConfigSchema
MapStringValue()
: Convertsmap[string]string
totypes.Map
ValueStringMap()
: Convertstypes.Map
tomap[string]string
toModelV0()
to handle labels from API responsetoSyntheticsMonitorConfig()
to include labels in API requestsDocumentation Updates
docs/resources/kibana_synthetics_monitor.md
Usage Example
API Compatibility
Technical Details
Field Definition
Map of String
in Terraform schemamap[string]string
in Go structs"labels,omitempty"
- field is omitted when emptyImplementation Notes
Unit Tests Added
TestMapStringValue
: Tests conversion frommap[string]string
totypes.Map
TestValueStringMap
: Tests conversion fromtypes.Map
tomap[string]string
TestLabelsFieldConversion
: Tests labels field conversion in API response processingTestToSyntheticsMonitorConfig
: Tests labels field conversion in API request creationAcceptance Tests Added
internal/kibana/synthetics/acc_test.go
TestSyntheticMonitorLabelsResource
httpMonitorLabelsConfig
: Creates monitor with 3 labels (environment=production, team=platform, service=web-app)httpMonitorLabelsUpdated
: Updates label values (environment=staging, team=platform-updated, service=web-app-v2)httpMonitorLabelsRemoved
: Removes all labels to test round-trip consistencyTesting Checklist
Files Modified
libs/go-kibana-rest/kbapi/api.kibana_synthetics.go
- Added Labels field to API structsinternal/kibana/synthetics/schema.go
- Added Labels field to Terraform schema and conversion functionsinternal/kibana/synthetics/schema_test.go
- Added comprehensive unit tests for Labels fieldinternal/kibana/synthetics/acc_test.go
- Added acceptance tests for Labels field (TestSyntheticMonitorLabelsResource)docs/resources/kibana_synthetics_monitor.md
- Updated documentation with Labels fieldPre-submission Checklist
Additional Notes
tags
Changelog Entry