Apache Mesos
metrics.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __MASTER_METRICS_HPP__
18 #define __MASTER_METRICS_HPP__
19 
20 #include <string>
21 #include <vector>
22 
26 
27 #include <stout/hashmap.hpp>
28 
29 #include "mesos/mesos.hpp"
30 #include "mesos/type_utils.hpp"
31 
32 namespace mesos {
33 namespace internal {
34 namespace master {
35 
36 class Master;
37 
38 struct Metrics
39 {
40  explicit Metrics(const Master& master);
41 
42  ~Metrics();
43 
46 
52 
57 
59 
60  // Task state metrics.
74 
77 
78  // NOTE: We only track metrics sources and reasons for terminal states.
80 
81  // Message counters.
83 
84  // Metrics specific to frameworks of a common principal.
85  // These metrics have names prefixed by "frameworks/<principal>/".
86  struct Frameworks
87  {
88  // Counters for messages from all frameworks of this principal.
89  // Note: We only count messages from active scheduler
90  // *instances* while they are *registered*. i.e., messages
91  // prior to the completion of (re)registration
92  // (AuthenticateMessage and (Re)RegisterFrameworkMessage) and
93  // messages from an inactive scheduler instance (after the
94  // framework has failed over) are not counted.
95 
96  // Framework messages received (before processing).
98 
99  // Framework messages processed.
100  // NOTE: This doesn't include dropped messages. Processing of
101  // a message may be throttled by a RateLimiter if one is
102  // configured for this principal. Also due to Master's
103  // asynchronous nature, this doesn't necessarily mean the work
104  // requested by this message has finished.
106 
107  explicit Frameworks(const std::string& principal)
108  : messages_received("frameworks/" + principal + "/messages_received"),
109  messages_processed("frameworks/" + principal + "/messages_processed")
110  {
111  process::metrics::add(messages_received);
112  process::metrics::add(messages_processed);
113  }
114 
116  {
117  process::metrics::remove(messages_received);
118  process::metrics::remove(messages_processed);
119  }
120  };
121 
122  // Per-framework-principal metrics keyed by the framework
123  // principal.
125 
126  // Messages from schedulers.
142 
143  // Messages from executors.
145 
146  // Messages from slaves.
153 
154  // Messages from both schedulers and slaves.
156 
161 
164 
167 
170 
171  // Recovery counters.
173 
174  // Process metrics.
178 
179  // Successful registry operations.
186 
187  // Slave observer metrics.
188  //
189  // TODO(neilc): The `slave_shutdowns_xxx` metrics are deprecated and
190  // will always be zero. Remove in Mesos 2.0.
194 
198 
199  // Non-revocable resources.
200  std::vector<process::metrics::PullGauge> resources_total;
201  std::vector<process::metrics::PullGauge> resources_used;
202  std::vector<process::metrics::PullGauge> resources_percent;
203 
204  // Revocable resources.
205  std::vector<process::metrics::PullGauge> resources_revocable_total;
206  std::vector<process::metrics::PullGauge> resources_revocable_used;
207  std::vector<process::metrics::PullGauge> resources_revocable_percent;
208 
210 
212  const TaskState& state,
213  const TaskStatus::Source& source,
214  const TaskStatus::Reason& reason);
215 };
216 
217 } // namespace master {
218 } // namespace internal {
219 } // namespace mesos {
220 
221 #endif // __MASTER_METRICS_HPP__
process::metrics::Counter messages_executor_to_framework
Definition: metrics.hpp:144
process::metrics::Counter messages_reregister_slave
Definition: metrics.hpp:148
~Frameworks()
Definition: metrics.hpp:115
process::metrics::PullGauge outstanding_offers
Definition: metrics.hpp:58
process::metrics::PullGauge frameworks_inactive
Definition: metrics.hpp:56
process::metrics::Counter messages_reregister_framework
Definition: metrics.hpp:128
process::metrics::Counter recovery_slave_removals
Definition: metrics.hpp:172
Definition: master.hpp:27
process::metrics::PullGauge tasks_killing
Definition: metrics.hpp:65
Future< Nothing > remove(const Metric &metric)
Definition: metrics.hpp:109
process::metrics::Counter tasks_finished
Definition: metrics.hpp:66
hashmap< TaskStatus::Source, Reasons > SourcesReasons
Definition: metrics.hpp:76
process::metrics::Counter messages_reconcile_tasks
Definition: metrics.hpp:139
process::metrics::PullGauge slaves_connected
Definition: metrics.hpp:47
std::vector< process::metrics::PullGauge > resources_total
Definition: metrics.hpp:200
process::metrics::Counter messages_deactivate_framework
Definition: metrics.hpp:130
process::metrics::Counter slave_unreachable_completed
Definition: metrics.hpp:196
process::metrics::Counter valid_status_updates
Definition: metrics.hpp:162
process::metrics::PullGauge event_queue_dispatches
Definition: metrics.hpp:176
process::metrics::Counter messages_update_slave
Definition: metrics.hpp:152
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2660
process::metrics::PullGauge tasks_unreachable
Definition: metrics.hpp:64
process::metrics::PullGauge tasks_staging
Definition: metrics.hpp:61
process::metrics::Counter slave_shutdowns_scheduled
Definition: metrics.hpp:191
void incrementTasksStates(const TaskState &state, const TaskStatus::Source &source, const TaskStatus::Reason &reason)
process::metrics::Counter messages_kill_task
Definition: metrics.hpp:131
process::metrics::Counter tasks_failed
Definition: metrics.hpp:67
void incrementInvalidSchedulerCalls(const scheduler::Call &call)
process::metrics::Counter valid_status_update_acknowledgements
Definition: metrics.hpp:165
process::metrics::Counter messages_processed
Definition: metrics.hpp:105
process::metrics::Counter tasks_lost
Definition: metrics.hpp:69
process::metrics::Counter slave_reregistrations
Definition: metrics.hpp:181
Future< Nothing > add(const T &metric)
Definition: metrics.hpp:95
hashmap< std::string, process::Owned< Frameworks > > frameworks
Definition: metrics.hpp:124
Definition: counter.hpp:26
std::vector< process::metrics::PullGauge > resources_revocable_total
Definition: metrics.hpp:205
Definition: hashmap.hpp:38
process::metrics::Counter messages_status_update_acknowledgement
Definition: metrics.hpp:132
process::metrics::Counter valid_framework_to_executor_messages
Definition: metrics.hpp:157
process::metrics::PullGauge slaves_disconnected
Definition: metrics.hpp:48
process::metrics::Counter messages_authenticate
Definition: metrics.hpp:155
process::metrics::Counter invalid_executor_to_framework_messages
Definition: metrics.hpp:160
process::metrics::PullGauge frameworks_active
Definition: metrics.hpp:55
std::vector< process::metrics::PullGauge > resources_revocable_used
Definition: metrics.hpp:206
process::metrics::Counter slave_unreachable_canceled
Definition: metrics.hpp:197
process::metrics::PullGauge event_queue_http_requests
Definition: metrics.hpp:177
process::metrics::Counter tasks_error
Definition: metrics.hpp:70
process::metrics::Counter valid_executor_to_framework_messages
Definition: metrics.hpp:159
Definition: pull_gauge.hpp:46
process::metrics::PullGauge tasks_running
Definition: metrics.hpp:63
std::vector< process::metrics::PullGauge > resources_percent
Definition: metrics.hpp:202
process::metrics::Counter tasks_gone
Definition: metrics.hpp:72
process::metrics::Counter messages_launch_tasks
Definition: metrics.hpp:134
process::metrics::Counter slave_unreachable_scheduled
Definition: metrics.hpp:195
process::metrics::Counter dropped_messages
Definition: metrics.hpp:82
process::metrics::Counter invalid_framework_to_executor_messages
Definition: metrics.hpp:158
Definition: spec.hpp:30
process::metrics::Counter messages_suppress_offers
Definition: metrics.hpp:137
process::metrics::PullGauge uptime_secs
Definition: metrics.hpp:44
process::metrics::PullGauge frameworks_disconnected
Definition: metrics.hpp:54
process::metrics::Counter slave_shutdowns_canceled
Definition: metrics.hpp:193
process::metrics::PullGauge slaves_inactive
Definition: metrics.hpp:50
Metrics(const Master &master)
process::metrics::Counter messages_status_update
Definition: metrics.hpp:150
process::metrics::Counter messages_revive_offers
Definition: metrics.hpp:136
process::metrics::Counter slave_removals
Definition: metrics.hpp:182
process::metrics::Counter tasks_killed
Definition: metrics.hpp:68
process::metrics::Counter messages_register_framework
Definition: metrics.hpp:127
process::metrics::Counter slave_shutdowns_completed
Definition: metrics.hpp:192
process::metrics::Counter messages_register_slave
Definition: metrics.hpp:147
process::metrics::PullGauge slaves_active
Definition: metrics.hpp:49
process::metrics::Counter slave_removals_reason_unregistered
Definition: metrics.hpp:184
process::metrics::Counter messages_operation_status_update_acknowledgement
Definition: metrics.hpp:141
Definition: attributes.hpp:24
process::metrics::Counter messages_exited_executor
Definition: metrics.hpp:151
process::metrics::Counter messages_resource_request
Definition: metrics.hpp:133
process::metrics::Counter messages_framework_to_executor
Definition: metrics.hpp:140
hashmap< TaskState, SourcesReasons > tasks_states
Definition: metrics.hpp:79
process::metrics::Counter slave_removals_reason_registered
Definition: metrics.hpp:185
process::metrics::Counter invalid_operation_status_update_acknowledgements
Definition: metrics.hpp:169
std::vector< process::metrics::PullGauge > resources_used
Definition: metrics.hpp:201
process::metrics::Counter messages_unregister_slave
Definition: metrics.hpp:149
process::metrics::Counter tasks_gone_by_operator
Definition: metrics.hpp:73
process::metrics::Counter messages_decline_offers
Definition: metrics.hpp:135
process::metrics::Counter messages_reconcile_operations
Definition: metrics.hpp:138
Definition: metrics.hpp:38
Frameworks(const std::string &principal)
Definition: metrics.hpp:107
process::metrics::Counter messages_unregister_framework
Definition: metrics.hpp:129
process::metrics::PullGauge tasks_starting
Definition: metrics.hpp:62
process::metrics::Counter messages_received
Definition: metrics.hpp:97
process::metrics::Counter invalid_status_updates
Definition: metrics.hpp:163
process::metrics::Counter invalid_status_update_acknowledgements
Definition: metrics.hpp:166
process::metrics::PullGauge frameworks_connected
Definition: metrics.hpp:53
Definition: master.hpp:426
std::vector< process::metrics::PullGauge > resources_revocable_percent
Definition: metrics.hpp:207
process::metrics::PullGauge event_queue_messages
Definition: metrics.hpp:175
process::metrics::Counter slave_removals_reason_unhealthy
Definition: metrics.hpp:183
hashmap< TaskStatus::Reason, process::metrics::Counter > Reasons
Definition: metrics.hpp:75
process::metrics::PullGauge slaves_unreachable
Definition: metrics.hpp:51
process::metrics::Counter valid_operation_status_update_acknowledgements
Definition: metrics.hpp:168
process::metrics::Counter slave_registrations
Definition: metrics.hpp:180
process::metrics::Counter tasks_dropped
Definition: metrics.hpp:71
process::metrics::PullGauge elected
Definition: metrics.hpp:45