Skip to content

Commit

Permalink
Remove kibana, version and useragent packages (#31665)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch authored May 20, 2022
1 parent b98101d commit 9605c28
Show file tree
Hide file tree
Showing 65 changed files with 402 additions and 1,591 deletions.
5 changes: 3 additions & 2 deletions dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
"time"

"github.com/elastic/beats/v7/libbeat/dashboards"
"github.com/elastic/beats/v7/libbeat/kibana"
"github.com/elastic/beats/v7/libbeat/version"
"github.com/elastic/elastic-agent-libs/kibana"
"github.com/elastic/elastic-agent-libs/transport/httpcommon"
)

Expand Down Expand Up @@ -79,7 +80,7 @@ func main() {
Path: u.Path,
SpaceID: *spaceID,
Transport: transport,
}, "Beat Development Tools")
}, "Beat Development Tools", version.GetDefaultVersion(), version.Commit(), version.BuildTime().String())
if err != nil {
log.Fatalf("Error while connecting to Kibana: %v", err)
}
Expand Down
50 changes: 25 additions & 25 deletions filebeat/fileset/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ import (

"github.com/pkg/errors"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/version"
)

// processorCompatibility defines a processor's minimum version requirements or
// a transformation to make it compatible.
type processorCompatibility struct {
checkVersion func(esVersion *common.Version) bool // Version check returns true if this check applies.
checkVersion func(esVersion *version.V) bool // Version check returns true if this check applies.
procType string // Elasticsearch Ingest Node processor type.
adaptConfig func(processor Processor, log *logp.Logger) (Processor, error) // Adapt the configuration to make it compatible.
}

var processorCompatibilityChecks = []processorCompatibility{
{
procType: "append",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.10.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.10.0"))
},
adaptConfig: replaceAppendAllowDuplicates,
},
{
procType: "community_id",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.12.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.12.0"))
},
adaptConfig: deleteProcessor,
},
{
procType: "set",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.9.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.9.0"))
},
adaptConfig: replaceSetIgnoreEmptyValue,
},
{
procType: "uri_parts",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.12.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.12.0"))
},
adaptConfig: deleteProcessor,
},
{
procType: "user_agent",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.0.0")) &&
!esVersion.LessThan(common.MustNewVersion("6.7.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.0.0")) &&
!esVersion.LessThan(version.MustNew("6.7.0"))
},
adaptConfig: func(processor Processor, _ *logp.Logger) (Processor, error) {
processor.Set("ecs", true)
Expand All @@ -78,38 +78,38 @@ var processorCompatibilityChecks = []processorCompatibility{
},
{
procType: "user_agent",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("6.7.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("6.7.0"))
},
adaptConfig: func(_ Processor, _ *logp.Logger) (Processor, error) {
return Processor{}, errors.New("user_agent processor requires option 'ecs: true', Elasticsearch 6.7 or newer required")
},
},
{
procType: "convert",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.13.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.13.0"))
},
adaptConfig: replaceConvertIP,
},
{
procType: "network_direction",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.13.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.13.0"))
},
adaptConfig: deleteProcessor,
},
{
procType: "registered_domain",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.13.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.13.0"))
},
adaptConfig: deleteProcessor,
},
{
procType: "*",
checkVersion: func(esVersion *common.Version) bool {
return esVersion.LessThan(common.MustNewVersion("7.9.0"))
checkVersion: func(esVersion *version.V) bool {
return esVersion.LessThan(version.MustNew("7.9.0"))
},
adaptConfig: removeDescription,
},
Expand Down Expand Up @@ -211,7 +211,7 @@ func (p *Processor) String() string {
// adaptPipelineForCompatibility iterates over all processors in the pipeline
// and adapts them for version of Elasticsearch used. Adapt can mean modifying
// processor options or removing the processor.
func AdaptPipelineForCompatibility(esVersion common.Version, pipelineID string, content map[string]interface{}, log *logp.Logger) (err error) {
func AdaptPipelineForCompatibility(esVersion version.V, pipelineID string, content map[string]interface{}, log *logp.Logger) (err error) {
log = log.With("pipeline_id", pipelineID)
// Adapt the main processors in the pipeline.
if err = adaptProcessorsForCompatibility(esVersion, content, "processors", false, log); err != nil {
Expand All @@ -221,7 +221,7 @@ func AdaptPipelineForCompatibility(esVersion common.Version, pipelineID string,
return adaptProcessorsForCompatibility(esVersion, content, "on_failure", true, log)
}

func adaptProcessorsForCompatibility(esVersion common.Version, content map[string]interface{}, section string, ignoreMissingsection bool, log *logp.Logger) (err error) {
func adaptProcessorsForCompatibility(esVersion version.V, content map[string]interface{}, section string, ignoreMissingsection bool, log *logp.Logger) (err error) {
p, ok := content[section]
if !ok {
if ignoreMissingsection {
Expand Down
Loading

0 comments on commit 9605c28

Please sign in to comment.