Skip to content

Conversation

@teresaromero
Copy link
Contributor

@teresaromero teresaromero commented Dec 16, 2025

When exporting a dashboard, tags that are shared (defined at kibana/tags.yml) where being also exported into kibana/tag folder.

Shared tags are managed by fleet when reading the tags.yml so exporting them as json is duplicating this tags in the UI.

This PR adds a filter layer when exporting a dashboard, removing shared tag objects and dashboard references to them.
Identification of tags is done based on fleet criteria on creating the json objects when reading the ´tags.yml´ file.

Updated unit tests to include shared tags object and check the filter is working as expected


func isSharedTag(aId string, sharedTags []string) bool {
for _, tag := range sharedTags {
id := fmt.Sprintf("tag-ref-%s-default", strings.ReplaceAll(strings.ToLower(tag), " ", "-"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the shared tag have more formatting than this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this format set by Fleet? Not sure if we can rely on it, it could be changed without previous notice.
Though we should not care a lot if we check by names instead of ids.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fleet is actually parsing a specific id for shared tags https://github.com/elastic/kibana/blob/5385f96a132114362b2542e6a44c96a697b66c28/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/tag_assets.ts#L67

i've reviewed the pr and have taken into account this format to identify the shared tags when exporting a dashboard.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach looks mostly good to me. I only wonder if we are relying on ids, when we are interested on the names, that is what users see.

Tried to re-export all Crowdstrike dashboards and the changes make sense to me 👍


func isSharedTag(aId string, sharedTags []string) bool {
for _, tag := range sharedTags {
id := fmt.Sprintf("tag-ref-%s-default", strings.ReplaceAll(strings.ToLower(tag), " ", "-"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this format set by Fleet? Not sure if we can rely on it, it could be changed without previous notice.
Though we should not care a lot if we check by names instead of ids.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. It is usually discouraged to use underscores in go files or package names, as some of them have special meanings (_test, _linux...).
Maybe this file could be called just removesharedtags.go, or we could merge all these files into a single tags.go.
Though I see there are already other files here with underscores.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i followed the naming i saw.. but agree, i think we can merge into a single one 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consolidated tag functions into new ´tag.go´ file

@teresaromero teresaromero changed the title [draft] implement shared tags functionality to avoid duplicates in exports Implement shared tags functionality to remove tags when dashboard export Dec 17, 2025
@teresaromero teresaromero marked this pull request as ready for review December 17, 2025 11:35
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Change Proposal] Add validation to avoid duplicate tags

3 participants