Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Add _cat/ml/anomaly_detectors API #51364

Merged
merged 2 commits into from
Jan 24, 2020

Conversation

benwtrent
Copy link
Member

@benwtrent benwtrent commented Jan 23, 2020

Adds new _cat/ml/anomaly_detectors and _cat/ml/anomaly_detectors/{job_id} endpoints

Example output:

GET /_cat/ml/anomaly_detectors?v
>
id                    state data.processed_records model.bytes model.memory_status forecast.total bucket.count
high_sum_total_sales closed 4674                   1.5mb                        ok 0              743
low_request_rate     closed 1216                   40.5kb                       ok 0              1457
response_code_rates  closed 14073                  132.7kb                      ok 0              1460
url_scanning         closed 14073                  501.7kb                      ok 0              1460

Same call but sorted

GET /_cat/ml/anomaly_detectors?v&s=dpr:desc
>
id                    state data.processed_records model.bytes model.memory_status forecast.total bucket.count
response_code_rates  closed 14073                  132.7kb                      ok 0              1460
url_scanning         closed 14073                  501.7kb                      ok 0              1460
high_sum_total_sales closed 4674                   1.5mb                        ok 0              743
low_request_rate     closed 1216                   40.5kb                       ok 0              1457

For specific jobs and only specific fields

GET /_cat/ml/anomaly_detectors/*rate*?v&h=id,dpr,mb
>
id                  dpr   mb
low_request_rate    1216  40.5kb
response_code_rates 28146 132.7kb

All other typical settings are supported as well.

Help output

id                               |                                    | the job_id                                                       
state                            | s                                  | the job state                                                    
opened_time                      | ot                                 | the amount of time the job has been opened                       
assignment_explanation           | ae                                 | why the job is or is not assigned to a node                      
data.processed_records           | dpr,dataProcessedRecords           | number of processed records                                      
data.processed_fields            | dpr,dataProcessedFields            | number of processed fields                                       
data.input_bytes                 | dib,dataInputBytes                 | total input bytes                                                
data.input_records               | dir,dataInputRecords               | total record count                                               
data.input_fields                | dif,dataInputFields                | total field count                                                
data.invalid_dates               | did,dataInvalidDates               | number of records with invalid dates                             
data.missing_fields              | dmf,dataMissingFields              | number of records with missing fields                            
data.out_of_order_timestamps     | doot,dataOutOfOrderTimestamps      | number of records handled out of order                           
data.empty_buckets               | deb,dataEmptyBuckes                | number of empty buckets                                          
data.sparse_buckets              | dsb,dataSparseBuckets              | number of sparse buckets                                         
data.buckets                     | db,dataBuckes                      | total bucket count                                               
data.earliest_record             | der,dataEarliestRecord             | earliest record time                                             
data.latest_record               | dlr,dataLatestRecord               | latest record time                                               
data.last                        | dl,dataLast                        | last time data was seen                                          
data.last_empty_bucket           | dleb,dataLastEmptyBucket           | last time an empty bucket occurred                               
data.last_sparse_bucket          | dlsb,dataLastSparseBucket          | last time a sparse bucket occurred                               
model.bytes                      | mb,modelBytes                      | model size                                                       
model.memory_status              | mms,modelMemoryStatus              | current memory status                                            
model.bytes_exceeded             | mbe,modelBytesExceeded             | how much the model has exceeded the limit                        
model.memory_limit               | mml,modelMemoryLimit               | model memory limit                                               
model.by_fields                  | mbf,modelByFields                  | count of 'by' fields                                             
model.over_fields                | mof,modelOverFields                | count of 'over' fields                                           
model.partition_fields           | mpf,modelPartitionFields           | count of 'partition' fields                                      
model.bucket_allocation_failures | mbaf,modelBucketAllocationFailures | number of bucket allocation failures                             
model.log_time                   | mlt,modelLogTime                   | when the model stats were gathered                               
model.timestamp                  | mt,modelTimestamp                  | the time of the last record when the model stats were gathered   
forecast.total                   | ft,forecastTotal                   | total number of forecasts                                        
forecast.memory.min              | fmmin,forecastMemoryMin            | minimum memory used by forecasts                                 
forecast.memory.max              | fmmax,forecastsMemoryMax           | maximum memory used by forecasts                                 
forecast.memory.avg              | fmavg,forecastMemoryAvg            | average memory used by forecasts                                 
forecast.memory.total            | fmt,forecastMemoryTotal            | total memory used by all forecasts                               
forecast.records.min             | frmin,forecastRecordsMin           | minimum record count for forecasts                               
forecast.records.max             | frmax,forecastRecordsMax           | maximum record count for forecasts                               
forecast.records.avg             | fravg,forecastRecordsAvg           | average record count for forecasts                               
forecast.records.total           | frt,forecastRecordsTotal           | total record count for all forecasts                             
forecast.time.min                | ftmin,forecastTimeMin              | minimum runtime for forecasts                                    
forecast.time.max                | ftmax,forecastTimeMax              | maximum run time for forecasts                                   
forecast.time.avg                | ftavg,forecastTimeAvg              | average runtime for all forecasts (milliseconds)                 
forecast.time.total              | ftt,forecastTimeTotal              | total runtime for all forecasts                                  
node.id                          | ni,nodeId                          | id of the assigned node                                          
node.name                        | nn,nodeName                        | name of the assigned node                                        
node.ephemeral_id                | ne,nodeEphemeralId                 | ephemeral id of the assigned node                                
node.address                     | na,nodeAddress                     | network address of the assigned node                             
bucket.count                     | bc,bucketCount                     | bucket count                                                     
bucket.time.total                | btt,bucketTimeTotal                | total bucket processing time                                     
bucket.time.min                  | btmin,bucketTimeMin                | minimum bucket processing time                                   
bucket.time.max                  | btmax,bucketTimeMax                | maximum bucket processing time                                   
bucket.time.exp_avg              | btea,bucketTimeExpAvg              | exponential average bucket processing time (milliseconds)        
bucket.time.exp_avg_hour         | bteah,bucketTimeExpAvgHour         | exponential average bucket processing time by hour (milliseconds)

@benwtrent benwtrent added :ml Machine learning v7.7.0 v8.0.0 labels Jan 23, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (:ml)

@benwtrent benwtrent changed the title [ML] Add _cat/ml/anomaly_detectors/_stats [ML] Add _cat/ml/anomaly_detectors/_stats API Jan 23, 2020
Copy link

@hendrikmuhs hendrikmuhs left a comment

Choose a reason for hiding this comment

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

LGTM, 2 typos and a nit

.build());
table.addCell("data.buckets",
TableColumnAttributeBuilder.builder("total bucket count", false)
.setAliases("db", "dataBuckes")

Choose a reason for hiding this comment

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

dataBuckes: missing "t"

.build());
table.addCell("data.empty_buckets",
TableColumnAttributeBuilder.builder("number of empty buckets", false)
.setAliases("deb", "dataEmptyBuckes")

Choose a reason for hiding this comment

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

dataBuckes: missing "t"

table.addCell(modelSizeStats == null ? null : modelSizeStats.getTimestamp());

ForecastStats forecastStats = job.getForecastStats();
table.addCell(forecastStats == null ? null : forecastStats.getTotal());

Choose a reason for hiding this comment

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

nit: a bool to avoid repeating forecastStats == null || forecastStats.getTotal() <= 0L for every cell?

Copy link
Member Author

Choose a reason for hiding this comment

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

For sure :). I was in fast editing mode (yy 7p) and tons of line duplications.

@sophiec20
Copy link
Contributor

I'm a great fan of using the _cat lists to grab quick info on indices, snapshots etc. With that in mind, I would propose we simplify the call and remove the _stats appendage.

In the same way that GET _cat/indices draws down info from GET index/_stats and GET index/_settings and wherever index health lives .. it seems more in keeping that the list of jobs (as pasted above) could be called using a simpler command i.e. GET _cat/ml/anomaly_detectors ..

The column selection seems good for the anomaly detection job list.

As we extend this to other ML components, there is great potential here to simplify tasks in Dev Tools when working with transforms -> data frame analytics -> trained models -> inference ... answering quick questions such as "What trained models do I have?".

Will this be available in Dev Tools auto complete?

@benwtrent
Copy link
Member Author

Will this be available in Dev Tools auto complete?

It can be. I am not sure how automatic that process is.

@hendrikmuhs
Copy link

Will this be available in Dev Tools auto complete?

It can be. I am not sure how automatic that process is.

Best to my knowledge: Completions are done via some script that runs over the REST specs. I do not know how often this is done. Afaik its not fully automated but executed manually on a regular basis.

That means, if you do nothing completions will be eventually there (given REST specs are in place).[*] To speed up the process you can open an issue, however it means extra work for both sides.

[*] Happened to me for 1 feature: I did not explicitly requested autocomplete and was happy to see it without me doing anything

@benwtrent benwtrent changed the title [ML] Add _cat/ml/anomaly_detectors/_stats API [ML] Add _cat/ml/anomaly_detectors API Jan 24, 2020
@benwtrent benwtrent merged commit a25f922 into elastic:master Jan 24, 2020
@benwtrent benwtrent deleted the feature/ml-_cat-jobs branch January 24, 2020 13:20
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Jan 24, 2020
* [ML] Add _cat/ml/anomaly_detectors/_stats

* addressing PR feedback
benwtrent added a commit that referenced this pull request Jan 24, 2020
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.

5 participants