/
oracle.flow
165 lines (148 loc) · 9.92 KB
/
oracle.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from signalfx.detectors.autodetect import utils
from signalfx.detectors.autodetect.infra.db import utils as db_utils
from signalfx.detectors.against_recent import against_recent
def session_utilization_detector(fire_threshold: float = 90,
fire_lasting: lasting = lasting('5m', 0.8),
clear_threshold: float = 90,
clear_lasting: lasting = lasting('5m', 0.8),
filter_: filter = None):
# Detects when Oracle session utilization is above threshold
# :param fire_threshold description=Specifies trigger threshold in % for the session utilization
# :param fire_threshold label=Trigger threshold (%)
# :param fire_threshold min=0
# :param fire_threshold max=100
# :param fire_threshold unit=%
# :param fire_lasting description=Specifies trigger sensitivity associated with trigger threshold
# :param fire_lasting label=Trigger sensitivity
# :param clear_threshold description=Specifies clear threshold in % for the session utilization
# :param clear_threshold label=Clear threshold (%)
# :param clear_threshold min=0
# :param clear_threshold max=100
# :param clear_threshold unit=%
# :param clear_threshold constraint=lte(fire_threshold)
# :param clear_lasting description=Specifies clear sensitivity associated with clear threshold
# :param clear_lasting label=Clear sensitivity
# :param filter_ description=Specifies dimensional scope of the detector
# :param filter_ metric_name=oracledb.sessions.usage
# :viz valueSuffix=%
# :return: detect block that triggers when Oracle session utilization is above the threshold
assert fire_threshold >= clear_threshold, utils.threshold_validation_err_msg(fire_threshold, clear_threshold,
orientation='above')
scope_filter = utils.merge_filters(db_utils.ORACLE_INSTANCE_NAME_FILTER, filter_)
current_utilization = data('oracledb.sessions.usage', filter=scope_filter).sum(by=db_utils.ORACLE_GROUP_BY)
resource_limit = data('oracledb.sessions.limit', filter=scope_filter).sum(by=db_utils.ORACLE_GROUP_BY)
stream = ((current_utilization / resource_limit) * 100)
fire_threshold_stream = const(fire_threshold)
clear_threshold_stream = const(clear_threshold)
ann = [utils.annotate_stream(stream, 'Session utilization'),
utils.annotate_fire_threshold(fire_threshold_stream, orientation='above')]
return detect(when(stream >= fire_threshold_stream, lasting = fire_lasting),
off=when(stream < clear_threshold_stream, lasting = clear_lasting),
annotations=ann,
auto_resolve_after=utils.AUTO_RESOLVE_AFTER)
def process_utilization_detector(fire_threshold: float = 90,
fire_lasting: lasting = lasting('5m', 0.8),
clear_threshold: float = 90,
clear_lasting: lasting = lasting('5m', 0.8),
filter_: filter = None):
# Detects when Oracle process utilization is above threshold
# :param fire_threshold description=Specifies trigger threshold in % for the process utilization
# :param fire_threshold label=Trigger threshold (%)
# :param fire_threshold min=0
# :param fire_threshold max=100
# :param fire_threshold unit=%
# :param fire_lasting description=Specifies trigger sensitivity associated with trigger threshold
# :param fire_lasting label=Trigger sensitivity
# :param clear_threshold description=Specifies clear threshold in % for the process utilization
# :param clear_threshold label=Clear threshold (%)
# :param clear_threshold min=0
# :param clear_threshold max=100
# :param clear_threshold unit=%
# :param clear_threshold constraint=lte(fire_threshold)
# :param clear_lasting description=Specifies clear sensitivity associated with clear threshold
# :param clear_lasting label=Clear sensitivity
# :param filter_ description=Specifies dimensional scope of the detector
# :param filter_ metric_name=oracledb.processes.usage
# :viz valueSuffix=%
# :return: Detect block that triggers when Oracle process utilization is above the threshold
assert fire_threshold >= clear_threshold, utils.threshold_validation_err_msg(fire_threshold, clear_threshold,
orientation='above')
scope_filter = utils.merge_filters(db_utils.ORACLE_INSTANCE_NAME_FILTER, filter_)
current_utilization = data('oracledb.processes.usage', filter=scope_filter).sum(by=db_utils.ORACLE_GROUP_BY)
resource_limit = data('oracledb.processes.limit', filter=scope_filter).sum(by=db_utils.ORACLE_GROUP_BY)
stream = ((current_utilization / resource_limit) * 100)
fire_threshold_stream = const(fire_threshold)
clear_threshold_stream = const(clear_threshold)
ann = [utils.annotate_stream(stream, 'Process utilization'),
utils.annotate_fire_threshold(fire_threshold_stream, orientation='above')]
return detect(when(stream >= fire_threshold_stream, lasting=fire_lasting),
off=when(stream < clear_threshold_stream, lasting=clear_lasting),
annotations=ann,
auto_resolve_after=utils.AUTO_RESOLVE_AFTER)
def tablespace_utilization_detector(fire_threshold: float = 95,
fire_lasting: lasting = lasting('5m', 0.8),
clear_threshold: float = 95,
clear_lasting: lasting = lasting('5m', 0.8),
filter_: filter = None):
# Detects when Oracle tablespace utilization is above threshold
# :param fire_threshold description=Specifies trigger threshold in % for the process utilization
# :param fire_threshold label=Trigger threshold (%)
# :param fire_threshold min=0
# :param fire_threshold max=100
# :param fire_threshold unit=%
# :param fire_lasting description=Specifies trigger sensitivity associated with trigger threshold
# :param fire_lasting label=Trigger sensitivity
# :param clear_threshold description=Specifies clear threshold in % for the process utilization
# :param clear_threshold label=Clear threshold (%)
# :param clear_threshold min=0
# :param clear_threshold max=100
# :param clear_threshold unit=%
# :param clear_threshold constraint=lte(fire_threshold)
# :param clear_lasting description=Specifies clear sensitivity associated with clear threshold
# :param clear_lasting label=Clear sensitivity
# :param filter_ description=Specifies dimensional scope of the detector
# :param filter_ metric_name=oracledb.tablespace_size.usage
# :viz valueSuffix=%
# :return: Detect block that triggers when Oracle tablespace utilization is above the threshold
assert fire_threshold >= clear_threshold, utils.threshold_validation_err_msg(fire_threshold, clear_threshold,
orientation='above')
scope_filter = utils.merge_filters(db_utils.ORACLE_INSTANCE_NAME_FILTER, filter_)
current_utilization = data('oracledb.tablespace_size.usage', filter=scope_filter).sum(by=db_utils.ORACLE_TABLESPACE_GROUP_BY)
resource_limit = data('oracledb.tablespace_size.limit', filter=scope_filter).sum(by=db_utils.ORACLE_TABLESPACE_GROUP_BY)
stream = ((current_utilization / resource_limit) * 100)
fire_threshold_stream = const(fire_threshold)
clear_threshold_stream = const(clear_threshold)
ann = [utils.annotate_stream(stream, 'Tablespace utilization'),
utils.annotate_fire_threshold(fire_threshold_stream, orientation='above')]
return detect(when(stream >= fire_threshold_stream, lasting=fire_lasting),
off=when(stream < clear_threshold_stream, lasting=clear_lasting),
annotations=ann,
auto_resolve_after=utils.AUTO_RESOLVE_AFTER)
def hard_parses_increase_detector(fire_num_stddev: float = 4.5,
current_window: duration = duration('20m'),
historical_window: duration = duration('3h'),
filter_: filter = None):
# :param fire_num_stddev label=Trigger deviation
# :param fire_num_stddev description=Expressed in standard deviations from baseline
# :param fire_num_stddev min=0
# :param fire_num_stddev step=0.1
# :param fire_num_stddev unit=SD
# :param current_window description=The time range being monitored
# :param current_window label=Evaluation window
# :param historical_window description=The time range being used to define the recent trend
# :param historical_window label=Historical window
# :param filter_ description=Specifies dimensional scope of the detector
# :param filter_ metric_name=oracledb.hard_parses
# :return: detect block that triggers when number of hard parses suddenly increased
scope_filter = utils.merge_filters(db_utils.ORACLE_INSTANCE_NAME_FILTER, filter_)
stream = data('oracledb.hard_parses', filter=scope_filter).sum(by=db_utils.ORACLE_GROUP_BY).publish(label='# Change in hard parses')
clear_num_stddev = max(fire_num_stddev - 0.5, 0)
return against_recent.detector_mean_std(stream=stream,
current_window=current_window,
historical_window=historical_window,
fire_num_stddev=fire_num_stddev,
clear_num_stddev=clear_num_stddev,
orientation='above',
ignore_extremes=True,
calculation_mode='vanilla',
auto_resolve_after=utils.AUTO_RESOLVE_AFTER)