Skip to content

Migrate obs-infraobs-integrations to package-spec v3 #1 - #8170

Merged
tommyers-elastic merged 52 commits into
elastic:mainfrom
shmsr:migrate-infraobs-ps-v3-batch-1-serverless
Oct 18, 2023
Merged

tommyers-elastic merged 52 commits into
elastic:mainfrom
shmsr:migrate-infraobs-ps-v3-batch-1-serverless

Conversation

@shmsr

@shmsr shmsr commented Oct 12, 2023 •

Copy link
Copy Markdown
Member

Migrate a batch of packages from v1/v2 to v3 package-spec. Used the following scripts and some manual changes to generate the changes in this PR:

yq_hack.zsh

#!/bin/bash

set -e
set -u
set -o pipefail
set -x

pushd $1

find data_stream -type f -path "*fields*" -name "*.yml" -exec yq e -i "del .[].release" {} \;
find data_stream -type f -path "*fields*" -name "ecs.yml" -exec yq e -i "unique_by(.name)" {} \;
find data_stream -type f -path "*fields*" -name "*.yml" -exec yq e -i "del .[].fields.[].required" {} \;

yq e -i 'del .release' manifest.yml
yq e -i "with(select(.license != null); .conditions.elastic.subscription = .license) | del .license" manifest.yml

popd

git add -u $1/
git commit -m "[$1]: migration with yq"

ecs-update.zsh

#!/bin/bash

set -u
set -o pipefail
set -x

echo "-- executing ecs-update for $1 --"

ecs-update -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type -owner elastic/obs-infraobs-integrations -v -skip-format=true $1

if (( $? )) 
then
    echo "-- write validation for $1 --"
    pushd $1

    go run ../scripting/write_validation.go

    popd

    # Try again?
    git checkout .
    ecs-update -format-version=3.0.0 -fix-dotted-yaml-keys -add-owner-type -owner elastic/obs-infraobs-integrations -v -skip-format=true $1
fi

And another Go program to write the validation.yml by parsing the elastic-package lint errors.

Then I hooked this scripts to run with:

$ pkgs=($(cat .github/CODEOWNERS | grep '@elastic/obs-infraobs-integrations' | cut -d ' ' -f 1 | cut -d '/' -f 3 | sort | uniq))

$ for ((idx=1; idx<=15; idx++))
do
scripting/yq_hack.zsh $pkgs[idx]
done
$ for ((idx=1; idx<=15; idx++))
do
scripting/ecs_update.zsh $pkgs[idx] || break
done

Another variation of the above script:

$ for ((idx=1; idx<=15; idx++))
do
case $pkgs[idx] in
  "citrix_adc" | "azure_app_service" | "apache") echo "-- skip $pkgs[idx] --";;
  "coredns" | "couchbase" | "etcd" | "cockroachdb" | "ceph" | "azure_functions" | "activemq" | "apache_spark" | "apache_tomcat" | "cassandra" | "couchdb" | "airflow") echo "-- done $pkgs[idx] --";;
  *) scripting/ecs_update.zsh $pkgs[idx] || break;;
esac
done

As I am creating a batch of 15 packages per migration, I am using a for loop. In case the migration is not possible for some packages, I put it in the first case to skip them.

Proposed commit message

Migrate packages owned by obs-infraobs-integrations but few couldn't be migrated. Marking them as follows:

  • activemq
  • airflow
  • apache
  • apache_spark
  • apache_tomcat
  • azure_app_service
  • azure_functions
  • cassandra
  • ceph
  • citrix_adc
  • cockroachdb
  • coredns
  • couchbase
  • couchdb
  • etcd

Please see the comment #8170 (comment) in this PR itself to understand why some packages couldn't be migrated and also learn about the challenges faced when migrating.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

@shmsr
shmsr requested a review from a team as a code owner October 12, 2023 06:25
@shmsr shmsr self-assigned this Oct 12, 2023
@shmsr

shmsr commented Oct 12, 2023 •

Copy link
Copy Markdown
Member Author

Here are some rough notes I recorded while migrating. I have fixed a few and accordingly improved my script. But there are 3 packages that couldn't be migrated.

  • airflow

    • Problem with duplicate field like container.name, container.image.name in ecs and agent.yml
  • apache

    • elastic: subscription already present (improve script)
    • duplicate field tags in error datastream
    • file "/Users/subhamsarkar/go/src/github.com/elastic/integrations/packages/apache/kibana/visualization/apache-22057f20-3a12-11eb-8946-296aab7b13db.json" is invalid: found legacy visualization "Uptime [Metrics Apache]" (metric, TSVB)
  • azure_app_service

    • Error: building package failed: resolving external fields failed: can't resolve fields: field geo.continent_name cannot be reused at top level (see: #1)
  • ceph

    • file "/Users/subhamsarkar/go/src/github.com/elastic/integrations/packages/ceph/data_stream/cluster_status/fields/fields.yml" is invalid: field 0.fields.0.fields.5.fields.5: object_type is required
      • Fixed by adding object_type: keyword (see: #1)
  • citrix_adc

    • Error: building package failed: resolving external fields failed: can't resolve fields: field interface.id cannot be reused at top level
  • cockroachdb

    • file "/Users/subhamsarkar/go/src/github.com/elastic/integrations/build/packages/cockroachdb-1.6.0.zip/data_stream/status/manifest.yml" is invalid: field elasticsearch.index_template.settings: Additional property index.mapping.dimension_fields.limit is not allowed
  • couchbase

    • file "/Users/subhamsarkar/go/src/github.com/elastic/integrations/build/packages/couchbase-1.3.1.zip/data_stream/query_index/fields/fields.yml" is invalid: field 0.fields.1.fields.0: Additional property metrics_type is not allowed
      • Will add to my script
  • cassandra

    • Normalize fields to make elastic-package test -v --report-format xUnit happy. (see: #1)
  • apache_spark

    • Normalize fields to make elastic-package test -v --report-format xUnit happy. (see: #1)

@elasticmachine

elasticmachine commented Oct 12, 2023 •

Copy link
Copy Markdown

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-10-17T16:50:08.864+0000

  • Duration: 27 min 16 sec

Test stats 🧪

Test Results
Failed 0
Passed 176
Skipped 0
Total 176

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine

elasticmachine commented Oct 12, 2023 •

Copy link
Copy Markdown

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (23/23) 💚
Files 100.0% (25/25) 💚 4.545
Classes 100.0% (25/25) 💚 4.545
Methods 93.2% (233/250) 👍 11.662
Lines 95.781% (2225/2323) 👍 6.256
Conditionals 100.0% (0/0) 💚

shmsr added 23 commits October 12, 2023 13:31
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/activemq
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/apache_spark
The format_version in the package manifest changed from 2.3.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/apache_tomcat
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/cassandra
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/couchdb
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/airflow
The format_version in the package manifest changed from 2.5.1 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/azure_functions
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/ceph
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/cockroachdb
The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/coredns
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/couchbase
The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/etcd
fields:
- name: count
type: long
description: Total number of Placement Groups (pgs) in cluster.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What was happeing to these fields before the individual mapping ?
What did the mapping look like ?

Also, under this group, are these the only sub fields that are there since we didn't have that clarity when type was object ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

before, the mapping just looks like this:

"state": {
  "type": "object"
},

which does nothing at all. the fields are mapped using default types, which are long and keyword respectively. so there's no behviour change here. it's just more explicit and intentional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the object is well defined in beats. i'm not sure why we never expclicity mapped them before.

type PgState struct {
	Count     int64  `json:"count"`
	StateName string `json:"state_name"`
}

external: ecs
- name: container.labels
external: ecs
- name: host

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tommyers-elastic , @andrewkroh - The host group ECS field reference is included in some integrations and some integrations doesn't include the ECS reference. As the host field is common, Is it worth adding validations for this field as well? Just a thought.
e.g. Integration not having host group field reference.

@tommyers-elastic
tommyers-elastic merged commit d63214f into elastic:main Oct 18, 2023
@elasticmachine

Copy link
Copy Markdown

Package activemq - 0.14.0 containing this change is available at https://epr.elastic.co/search?package=activemq

@elasticmachine

Copy link
Copy Markdown

Package airflow - 0.5.0 containing this change is available at https://epr.elastic.co/search?package=airflow

@elasticmachine

Copy link
Copy Markdown

Package apache_spark - 0.8.0 containing this change is available at https://epr.elastic.co/search?package=apache_spark

@elasticmachine

Copy link
Copy Markdown

Package azure_functions - 0.2.0 containing this change is available at https://epr.elastic.co/search?package=azure_functions

@elasticmachine

Copy link
Copy Markdown

Package cassandra - 1.10.0 containing this change is available at https://epr.elastic.co/search?package=cassandra

@elasticmachine

Copy link
Copy Markdown

Package ceph - 1.1.0 containing this change is available at https://epr.elastic.co/search?package=ceph

@elasticmachine

Copy link
Copy Markdown

Package cockroachdb - 1.7.0 containing this change is available at https://epr.elastic.co/search?package=cockroachdb

@elasticmachine

Copy link
Copy Markdown

Package coredns - 0.6.0 containing this change is available at https://epr.elastic.co/search?package=coredns

@elasticmachine

Copy link
Copy Markdown

Package couchbase - 1.4.0 containing this change is available at https://epr.elastic.co/search?package=couchbase

@elasticmachine

Copy link
Copy Markdown

Package couchdb - 1.1.0 containing this change is available at https://epr.elastic.co/search?package=couchdb

@elasticmachine

Copy link
Copy Markdown

Package etcd - 0.6.0 containing this change is available at https://epr.elastic.co/search?package=etcd

@shmsr
shmsr deleted the migrate-infraobs-ps-v3-batch-1-serverless branch October 30, 2023 16:51
orestisfl pushed a commit to orestisfl/integrations that referenced this pull request May 15, 2026
…ic#8170)

* [activemq]: migration with yq

* [airflow]: migration with yq

* [apache]: migration with yq

* [apache_spark]: migration with yq

* [cassandra]: migration with yq

* [cockroachdb]: migration with yq

* [couchbase]: migration with yq

* [couchdb]: migration with yq

* [etcd]: migration with yq

* [activemq] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/activemq

* [apache_spark] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/apache_spark

* [apache_tomcat] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 2.3.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/apache_tomcat

* [cassandra] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/cassandra

* [couchdb] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/couchdb

* [airflow] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/airflow

* [azure_functions] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 2.5.1 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/azure_functions

* [ceph] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/ceph

* [cockroachdb] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/cockroachdb

* [coredns] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 2.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/coredns

* [couchbase]: migration with yq

* [couchbase] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/couchbase

* [etcd] - removed dotted YAML keys from manifest

The format_version in the package manifest changed from 1.0.0 to 3.0.0. Removed
dotted YAML keys from package manifest. Added 'owner.type: elastic' to package
manifest.

[git-generate]
go run github.com/andrewkroh/go-examples/ecs-update@latest -v -format-version=3.0.0 -skip-format -fix-dotted-yaml-keys -add-owner-type packages/etcd

* Add validation.yml

* Set correct PR number in changelog

* Revert "[apache]: migration with yq"

This reverts commit 1ea1e883119b54df303d4fc14c9bf4e2e270d32d.

* [apache_spark]: normalize fields

* [cassandra]: normalize fields

* [apache_spark]: fix formatting to make ci happy

* [cassandra]: fix formatting to make ci happy

* Format packages and quote fields where necessary

* [couchbase]: s/metrics_type/metric_type

* [airflow]: remove duplicates from agent.yml instead of ecs.yml

* [cockroachdb]: remove duplicates from agent.yml instead of ecs.yml

* revert changes for packages for which v3 migration failed

* Format packages and quote fields where necessary

* Fix inconsistency w/ elastic-build

* quote fields where necessary

* Move container.labels to ecs.yml

* Change type from object to unsinged_long

* [ceph]: Explicit mapping for state.count and state.state_name

* [apache_spark]: migration with yq

* [apache_spark]: pass elastic-packge test static

* [apache_spark]: format

* [apache_spark]: format

* Make event.type's value formatting consistent

* Change type from nested to group

* Change type from unsigned_long to long

* Quote index.mapping.dimension_fields.limit to avoid getting changed by ep format

* Revert "Quote index.mapping.dimension_fields.limit to avoid getting changed by ep format"

This reverts commit 33308b60ba42dd370d2aaa8b7a933ba3bf64a77f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants