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
labelsfield 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.goLabels map[string]stringfield toSyntheticsMonitorConfigstruct with JSON tag"labels,omitempty"Labels map[string]stringfield toSyntheticsMonitorstruct with JSON tag"labels,omitempty"Terraform Schema Updates
internal/kibana/synthetics/schema.goLabels types.Mapfield totfModelV0struct with tfsdk tag"labels"schema.MapAttributewithtypes.StringTypeelements tomonitorConfigSchemaMapStringValue(): Convertsmap[string]stringtotypes.MapValueStringMap(): Convertstypes.Maptomap[string]stringtoModelV0()to handle labels from API responsetoSyntheticsMonitorConfig()to include labels in API requestsDocumentation Updates
docs/resources/kibana_synthetics_monitor.mdUsage Example
API Compatibility
Technical Details
Field Definition
Map of Stringin Terraform schemamap[string]stringin Go structs"labels,omitempty"- field is omitted when emptyImplementation Notes
Unit Tests Added
TestMapStringValue: Tests conversion frommap[string]stringtotypes.MapTestValueStringMap: Tests conversion fromtypes.Maptomap[string]stringTestLabelsFieldConversion: Tests labels field conversion in API response processingTestToSyntheticsMonitorConfig: Tests labels field conversion in API request creationAcceptance Tests Added
internal/kibana/synthetics/acc_test.goTestSyntheticMonitorLabelsResourcehttpMonitorLabelsConfig: 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
tagsChangelog Entry