Skip to content

Commit

Permalink
[Asset Inventory] Update index to match Index Template (#2262)
Browse files Browse the repository at this point in the history
Update index to match datastream integration format
  • Loading branch information
romulets committed Jun 7, 2024
1 parent 819cf57 commit d3f3dda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/samber/lo"
)

const indexTemplate = "logs-cloud_asset_inventory.asset_inventory-%s_%s_%s_%s-default"

type AssetInventory struct {
fetchers []AssetFetcher
publisher AssetPublisher
Expand Down Expand Up @@ -119,7 +121,7 @@ func (a *AssetInventory) publish(assets []AssetEvent) {
}

func generateIndex(a Asset) string {
return fmt.Sprintf("asset_inventory_%s_%s_%s_%s", a.Category, a.SubCategory, a.Type, a.SubType)
return fmt.Sprintf(indexTemplate, a.Category, a.SubCategory, a.Type, a.SubType)
}

func (a *AssetInventory) Stop() {
Expand Down
2 changes: 1 addition & 1 deletion internal/inventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAssetInventory_Run(t *testing.T) {
now := func() time.Time { return time.Date(2024, 1, 1, 1, 1, 1, 0, time.Local) }
expected := []beat.Event{
{
Meta: mapstr.M{libevents.FieldMetaIndex: "asset_inventory_infrastructure_compute_virtual-machine_ec2"},
Meta: mapstr.M{libevents.FieldMetaIndex: "logs-cloud_asset_inventory.asset_inventory-infrastructure_compute_virtual-machine_ec2-default"},
Timestamp: now(),
Fields: mapstr.M{
"asset": Asset{
Expand Down

0 comments on commit d3f3dda

Please sign in to comment.