putjob

package
v9.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Create an anomaly detection job.

If you include a `datafeed_config`, you must have read index privileges on the source index. If you include a `datafeed_config` but do not provide a query, the datafeed uses `{"match_all": {"boost": 1}}`.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type NewPutJob

type NewPutJob func(jobid string) *PutJob

NewPutJob type alias for index.

func NewPutJobFunc

func NewPutJobFunc(tp elastictransport.Interface) NewPutJob

NewPutJobFunc returns a new instance of PutJob with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type PutJob

type PutJob struct {
	// contains filtered or unexported fields
}

func New

Create an anomaly detection job.

If you include a `datafeed_config`, you must have read index privileges on the source index. If you include a `datafeed_config` but do not provide a query, the datafeed uses `{"match_all": {"boost": 1}}`.

https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-ml-put-job

func (*PutJob) AllowLazyOpen

func (r *PutJob) AllowLazyOpen(allowlazyopen bool) *PutJob

Advanced configuration option. Specifies whether this job can open when there is insufficient machine learning node capacity for it to be immediately assigned to a node. By default, if a machine learning node with capacity to run the job cannot immediately be found, the open anomaly detection jobs API returns an error. However, this is also subject to the cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. If this option is set to true, the open anomaly detection jobs API does not return an error and the job waits in the opening state until sufficient machine learning node capacity is available. API name: allow_lazy_open

func (*PutJob) AllowNoIndices

func (r *PutJob) AllowNoIndices(allownoindices bool) *PutJob

AllowNoIndices If `true`, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the `_all` string or when no indices are specified. API name: allow_no_indices

func (*PutJob) AnalysisConfig

func (r *PutJob) AnalysisConfig(analysisconfig types.AnalysisConfigVariant) *PutJob

Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational. API name: analysis_config

func (*PutJob) AnalysisLimits

func (r *PutJob) AnalysisLimits(analysislimits types.AnalysisLimitsVariant) *PutJob

Limits can be applied for the resources required to hold the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes. API name: analysis_limits

func (*PutJob) BackgroundPersistInterval

func (r *PutJob) BackgroundPersistInterval(duration types.DurationVariant) *PutJob

Advanced configuration option. The time between each periodic persistence of the model. The default value is a randomized value between 3 to 4 hours, which avoids all jobs persisting at exactly the same time. The smallest allowed value is 1 hour. For very large models (several GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` value too low. API name: background_persist_interval

func (*PutJob) CustomSettings

func (r *PutJob) CustomSettings(customsettings json.RawMessage) *PutJob

Advanced configuration option. Contains custom meta data about the job. API name: custom_settings

func (*PutJob) DailyModelSnapshotRetentionAfterDays

func (r *PutJob) DailyModelSnapshotRetentionAfterDays(dailymodelsnapshotretentionafterdays int64) *PutJob

Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies a period of time (in days) after which only the first snapshot per day is retained. This period is relative to the timestamp of the most recent snapshot for this job. Valid values range from 0 to `model_snapshot_retention_days`. API name: daily_model_snapshot_retention_after_days

func (*PutJob) DataDescription

func (r *PutJob) DataDescription(datadescription types.DataDescriptionVariant) *PutJob

Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post data API, it is not stored in Elasticsearch. Only the results for anomaly detection are retained. API name: data_description

func (*PutJob) DatafeedConfig

func (r *PutJob) DatafeedConfig(datafeedconfig types.DatafeedConfigVariant) *PutJob

Defines a datafeed for the anomaly detection job. If Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had at the time of creation and runs the query using those same roles. If you provide secondary authorization headers, those credentials are used instead. API name: datafeed_config

func (*PutJob) Description

func (r *PutJob) Description(description string) *PutJob

A description of the job. API name: description

func (PutJob) Do

func (r PutJob) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a putjob.Response

func (*PutJob) ErrorTrace

func (r *PutJob) ErrorTrace(errortrace bool) *PutJob

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace

func (*PutJob) ExpandWildcards

func (r *PutJob) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *PutJob

ExpandWildcards Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values. Valid values are:

* `all`: Match any data stream or index, including hidden ones. * `closed`: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed. * `hidden`: Match hidden data streams and hidden indices. Must be combined with `open`, `closed`, or both. * `none`: Wildcard patterns are not accepted. * `open`: Match open, non-hidden indices. Also matches any non-hidden data stream. API name: expand_wildcards

func (*PutJob) FilterPath

func (r *PutJob) FilterPath(filterpaths ...string) *PutJob

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*PutJob) Groups

func (r *PutJob) Groups(groups ...string) *PutJob

A list of job groups. A job can belong to no groups or many. API name: groups

func (*PutJob) Header

func (r *PutJob) Header(key, value string) *PutJob

Header set a key, value pair in the PutJob headers map.

func (*PutJob) HttpRequest

func (r *PutJob) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*PutJob) Human

func (r *PutJob) Human(human bool) *PutJob

Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human

func (*PutJob) IgnoreThrottled

func (r *PutJob) IgnoreThrottled(ignorethrottled bool) *PutJob

IgnoreThrottled If `true`, concrete, expanded or aliased indices are ignored when frozen. API name: ignore_throttled

func (*PutJob) IgnoreUnavailable

func (r *PutJob) IgnoreUnavailable(ignoreunavailable bool) *PutJob

IgnoreUnavailable If `true`, unavailable indices (missing or closed) are ignored. API name: ignore_unavailable

func (*PutJob) ModelPlotConfig

func (r *PutJob) ModelPlotConfig(modelplotconfig types.ModelPlotConfigVariant) *PutJob

This advanced configuration option stores model information along with the results. It provides a more detailed view into anomaly detection. If you enable model plot it can add considerable overhead to the performance of the system; it is not feasible for jobs with many entities. Model plot provides a simplified and indicative view of the model and its bounds. It does not display complex features such as multivariate correlations or multimodal data. As such, anomalies may occasionally be reported which cannot be seen in the model plot. Model plot config can be configured when the job is created or updated later. It must be disabled if performance issues are experienced. API name: model_plot_config

func (*PutJob) ModelSnapshotRetentionDays

func (r *PutJob) ModelSnapshotRetentionDays(modelsnapshotretentiondays int64) *PutJob

Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies the maximum period of time (in days) that snapshots are retained. This period is relative to the timestamp of the most recent snapshot for this job. By default, snapshots ten days older than the newest snapshot are deleted. API name: model_snapshot_retention_days

func (PutJob) Perform

func (r PutJob) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*PutJob) Pretty

func (r *PutJob) Pretty(pretty bool) *PutJob

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty

func (*PutJob) Raw

func (r *PutJob) Raw(raw io.Reader) *PutJob

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*PutJob) RenormalizationWindowDays

func (r *PutJob) RenormalizationWindowDays(renormalizationwindowdays int64) *PutJob

Advanced configuration option. The period over which adjustments to the score are applied, as new data is seen. The default value is the longer of 30 days or 100 bucket spans. API name: renormalization_window_days

func (*PutJob) Request

func (r *PutJob) Request(req *Request) *PutJob

Request allows to set the request property with the appropriate payload.

func (*PutJob) ResultsIndexName

func (r *PutJob) ResultsIndexName(indexname string) *PutJob

A text string that affects the name of the machine learning results index. By default, the job generates an index named `.ml-anomalies-shared`. API name: results_index_name

func (*PutJob) ResultsRetentionDays

func (r *PutJob) ResultsRetentionDays(resultsretentiondays int64) *PutJob

Advanced configuration option. The period of time (in days) that results are retained. Age is calculated relative to the timestamp of the latest bucket result. If this property has a non-null value, once per day at 00:30 (server time), results that are the specified number of days older than the latest bucket result are deleted from Elasticsearch. The default value is null, which means all results are retained. Annotations generated by the system also count as results for retention purposes; they are deleted after the same number of days as results. Annotations added by users are retained forever. API name: results_retention_days

type Request

type Request struct {

	// AllowLazyOpen Advanced configuration option. Specifies whether this job can open when there
	// is insufficient machine learning node capacity for it to be immediately
	// assigned to a node. By default, if a machine learning node with capacity to
	// run the job cannot immediately be found, the open anomaly detection jobs API
	// returns an error. However, this is also subject to the cluster-wide
	// `xpack.ml.max_lazy_ml_nodes` setting. If this option is set to true, the open
	// anomaly detection jobs API does not return an error and the job waits in the
	// opening state until sufficient machine learning node capacity is available.
	AllowLazyOpen *bool `json:"allow_lazy_open,omitempty"`
	// AnalysisConfig Specifies how to analyze the data. After you create a job, you cannot change
	// the analysis configuration; all the properties are informational.
	AnalysisConfig types.AnalysisConfig `json:"analysis_config"`
	// AnalysisLimits Limits can be applied for the resources required to hold the mathematical
	// models in memory. These limits are approximate and can be set per job. They
	// do not control the memory used by other processes, for example the
	// Elasticsearch Java processes.
	AnalysisLimits *types.AnalysisLimits `json:"analysis_limits,omitempty"`
	// BackgroundPersistInterval Advanced configuration option. The time between each periodic persistence of
	// the model. The default value is a randomized value between 3 to 4 hours,
	// which avoids all jobs persisting at exactly the same time. The smallest
	// allowed value is 1 hour. For very large models (several GB), persistence
	// could take 10-20 minutes, so do not set the `background_persist_interval`
	// value too low.
	BackgroundPersistInterval types.Duration `json:"background_persist_interval,omitempty"`
	// CustomSettings Advanced configuration option. Contains custom meta data about the job.
	CustomSettings json.RawMessage `json:"custom_settings,omitempty"`
	// DailyModelSnapshotRetentionAfterDays Advanced configuration option, which affects the automatic removal of old
	// model snapshots for this job. It specifies a period of time (in days) after
	// which only the first snapshot per day is retained. This period is relative to
	// the timestamp of the most recent snapshot for this job. Valid values range
	// from 0 to `model_snapshot_retention_days`.
	DailyModelSnapshotRetentionAfterDays *int64 `json:"daily_model_snapshot_retention_after_days,omitempty"`
	// DataDescription Defines the format of the input data when you send data to the job by using
	// the post data API. Note that when configure a datafeed, these properties are
	// automatically set. When data is received via the post data API, it is not
	// stored in Elasticsearch. Only the results for anomaly detection are retained.
	DataDescription types.DataDescription `json:"data_description"`
	// DatafeedConfig Defines a datafeed for the anomaly detection job. If Elasticsearch security
	// features are enabled, your datafeed remembers which roles the user who
	// created it had at the time of creation and runs the query using those same
	// roles. If you provide secondary authorization headers, those credentials are
	// used instead.
	DatafeedConfig *types.DatafeedConfig `json:"datafeed_config,omitempty"`
	// Description A description of the job.
	Description *string `json:"description,omitempty"`
	// Groups A list of job groups. A job can belong to no groups or many.
	Groups []string `json:"groups,omitempty"`
	// JobId The identifier for the anomaly detection job. This identifier can contain
	// lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It
	// must start and end with alphanumeric characters.
	JobId *string `json:"job_id,omitempty"`
	// ModelPlotConfig This advanced configuration option stores model information along with the
	// results. It provides a more detailed view into anomaly detection. If you
	// enable model plot it can add considerable overhead to the performance of the
	// system; it is not feasible for jobs with many entities. Model plot provides a
	// simplified and indicative view of the model and its bounds. It does not
	// display complex features such as multivariate correlations or multimodal
	// data. As such, anomalies may occasionally be reported which cannot be seen in
	// the model plot. Model plot config can be configured when the job is created
	// or updated later. It must be disabled if performance issues are experienced.
	ModelPlotConfig *types.ModelPlotConfig `json:"model_plot_config,omitempty"`
	// ModelSnapshotRetentionDays Advanced configuration option, which affects the automatic removal of old
	// model snapshots for this job. It specifies the maximum period of time (in
	// days) that snapshots are retained. This period is relative to the timestamp
	// of the most recent snapshot for this job. By default, snapshots ten days
	// older than the newest snapshot are deleted.
	ModelSnapshotRetentionDays *int64 `json:"model_snapshot_retention_days,omitempty"`
	// RenormalizationWindowDays Advanced configuration option. The period over which adjustments to the score
	// are applied, as new data is seen. The default value is the longer of 30 days
	// or 100 bucket spans.
	RenormalizationWindowDays *int64 `json:"renormalization_window_days,omitempty"`
	// ResultsIndexName A text string that affects the name of the machine learning results index. By
	// default, the job generates an index named `.ml-anomalies-shared`.
	ResultsIndexName *string `json:"results_index_name,omitempty"`
	// ResultsRetentionDays Advanced configuration option. The period of time (in days) that results are
	// retained. Age is calculated relative to the timestamp of the latest bucket
	// result. If this property has a non-null value, once per day at 00:30 (server
	// time), results that are the specified number of days older than the latest
	// bucket result are deleted from Elasticsearch. The default value is null,
	// which means all results are retained. Annotations generated by the system
	// also count as results for retention purposes; they are deleted after the same
	// number of days as results. Annotations added by users are retained forever.
	ResultsRetentionDays *int64 `json:"results_retention_days,omitempty"`
}

Request holds the request body struct for the package putjob

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/ml/put_job/MlPutJobRequest.ts#L30-L157

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON

func (s *Request) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	AllowLazyOpen                        bool                     `json:"allow_lazy_open"`
	AnalysisConfig                       types.AnalysisConfigRead `json:"analysis_config"`
	AnalysisLimits                       types.AnalysisLimits     `json:"analysis_limits"`
	BackgroundPersistInterval            types.Duration           `json:"background_persist_interval,omitempty"`
	CreateTime                           types.DateTime           `json:"create_time"`
	CustomSettings                       json.RawMessage          `json:"custom_settings,omitempty"`
	DailyModelSnapshotRetentionAfterDays int64                    `json:"daily_model_snapshot_retention_after_days"`
	DataDescription                      types.DataDescription    `json:"data_description"`
	DatafeedConfig                       *types.MLDatafeed        `json:"datafeed_config,omitempty"`
	Description                          *string                  `json:"description,omitempty"`
	Groups                               []string                 `json:"groups,omitempty"`
	JobId                                string                   `json:"job_id"`
	JobType                              string                   `json:"job_type"`
	JobVersion                           string                   `json:"job_version"`
	ModelPlotConfig                      *types.ModelPlotConfig   `json:"model_plot_config,omitempty"`
	ModelSnapshotId                      *string                  `json:"model_snapshot_id,omitempty"`
	ModelSnapshotRetentionDays           int64                    `json:"model_snapshot_retention_days"`
	RenormalizationWindowDays            *int64                   `json:"renormalization_window_days,omitempty"`
	ResultsIndexName                     string                   `json:"results_index_name"`
	ResultsRetentionDays                 *int64                   `json:"results_retention_days,omitempty"`
}

Response holds the response body struct for the package putjob

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/ml/put_job/MlPutJobResponse.ts#L29-L52

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

func (*Response) UnmarshalJSON

func (s *Response) UnmarshalJSON(data []byte) error