1
+ [role="xpack"]
1
2
[[ml-configuring-url]]
2
- === Adding Custom URLs To Machine Learning Results
3
+ === Adding custom URLs to machine learning results
3
4
4
5
When you create an advanced job or edit any job in {kib}, you can optionally
5
- attach one or more custom URLs. You can also specify these custom settings when
6
- you create or update jobs by using the {ml} APIs.
6
+ attach one or more custom URLs.
7
7
8
- The custom URLs provide links from the anomalies table in the Anomaly Explorer
9
- or Single Metric Viewer window in {kib} to custom dashboards or external
10
- websites. For example, you can define a custom URL that provides a way for users
11
- to drill down to the source data from the results set.
8
+ The custom URLs provide links from the anomalies table in the *Anomaly Explorer*
9
+ or *Single Metric Viewer* window in {kib} to {kib} dashboards, the *Discovery*
10
+ page, or external websites. For example, you can define a custom URL that
11
+ provides a way for users to drill down to the source data from the results set.
12
+
13
+ When you edit a job in {kib}, it simplifies the creation of the custom URLs for
14
+ {kib} dashboards and the *Discover* page and it enables you to test your URLs.
15
+ For example:
16
+
17
+ [role="screenshot"]
18
+ image::images/ml-customurl-edit.jpg["Edit a job to add a custom URL"]
12
19
13
20
For each custom URL, you must supply the URL and a label, which is the link text
14
- that appears in the anomalies table.
21
+ that appears in the anomalies table. You can also optionally supply a time
22
+ range. For example, these are the values that are added for `My link 1`:
23
+
24
+ [role="screenshot"]
25
+ image::images/ml-customurl-detail.jpg["An example of a label and URL"]
26
+
27
+ As in this case, the custom URL can contain
28
+ <<ml-configuring-url-strings,dollar sign delimited tokens>>, which
29
+ are populated when you click the link in the anomalies table. In this example,
30
+ the custom URL contains `$earliest$`, `$latest$`, and `$service$` tokens, which
31
+ pass the beginning and end of the time span of the selected anomaly and the
32
+ pertinent `service` field value to the target page. If you were interested in the following anomaly, for example:
15
33
16
34
[role="screenshot"]
17
- image::images/ml-customurl.jpg["Links in the Anomaly Explorer anoamilies table"]
35
+ image::images/ml-customurl.jpg["An example of the custom URL links in the Anomaly Explorer anomalies table"]
36
+
37
+ ...clicking `My Link 1` opens the *Discover* page and shows results for the
38
+ service and date that were identified in the anomaly:
39
+
40
+ [role="screenshot"]
41
+ image::images/ml-customurl-discover.jpg["An example of the results on the Discover page"]
42
+
43
+ Since we specified a time range of 2 hours, the time filter restricts the
44
+ results to the time period two hours before and after the anomaly.
45
+
46
+ You can also specify these custom URL settings when you create or update jobs by
47
+ using the {ml} APIs.
18
48
19
49
[float]
50
+ [[ml-configuring-url-strings]]
20
51
==== String Substitution in Custom URLs
21
52
22
53
You can use dollar sign ($) delimited tokens in a custom URL. These tokens are
@@ -40,7 +71,8 @@ span of the selected anomaly to the target page. The tokens are substituted with
40
71
date-time strings in ISO-8601 format. If you selected an interval of 1 hour for
41
72
the anomalies table, these tokens use one hour on either side of the anomaly
42
73
time as the earliest and latest times. The same is also true if the interval is
43
- set to `Auto` and a one hour interval was chosen.
74
+ set to `Auto` and a one hour interval was chosen. You can override this behavior
75
+ by using the `time_range` setting.
44
76
45
77
The `$mlcategoryregex$` and `$mlcategoryterms$` tokens pertain to jobs where you
46
78
are categorizing field values. For more information about this type of analysis,
@@ -55,28 +87,32 @@ the selected anomaly. Each categorization term is prefixed by a plus (+)
55
87
character, so that when the token is passed to a {kib} dashboard, the resulting
56
88
dashboard query seeks a match for all of the terms of the category.
57
89
58
- For example, the following API updates a `log_categories` job to add a custom
59
- URL that uses `$earliest$`, `$latest$`, and `$mlcategoryterms$` tokens:
90
+ For example, the following API updates a job to add a custom URL that uses
91
+ `$earliest$`, `$latest$`, and `$mlcategoryterms$` tokens:
60
92
61
93
[source,js]
62
94
----------------------------------
63
- POST _xpack/ml/anomaly_detectors/log_categories /_update
95
+ POST _xpack/ml/anomaly_detectors/sample_job /_update
64
96
{
65
97
"custom_settings": {
66
98
"custom_urls": [
67
99
{
68
100
"url_name": "test-link1",
101
+ "time_range": "1h",
69
102
"url_value": "http://localhost:5601/app/kibana#/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:'$earliest$',mode:quick,to:'$latest$'))&_a=(columns:!(_source),index:AV3OWB68ue3Ht69t29aw,interval:auto,query:(query_string:(analyze_wildcard:!t,query:'$mlcategoryterms$')),sort:!(time,desc))"
70
103
}
71
104
]
72
105
}
73
106
}
74
107
----------------------------------
108
+ //CONSOLE
109
+ //TEST[setup:sample_job]
75
110
76
111
When you click this custom URL in the anomalies table in {kib}, it opens up the
77
- Discover page and displays source data for the period when the anomaly occurred.
78
- Since this job was categorizing log messages, some `$mlcategoryterms$` token
79
- values that were passed to the target page for an example anomaly are as follows:
112
+ *Discover* page and displays source data for the period one hour before and
113
+ after the anomaly occurred. Since this job was categorizing log messages, some
114
+ `$mlcategoryterms$` token values that were passed to the target page for an
115
+ example anomaly are as follows:
80
116
81
117
[role="screenshot"]
82
118
image::images/ml-categoryterms.jpg["A query for category terms on the Discover page in {kib}"]
0 commit comments