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  {
113  }
114 
116  {
119  }
120  };
121 
122  // Per-framework-principal metrics keyed by the framework
123  // principal.
125 
126  // Messages from schedulers.
140 
141  // Messages from executors.
143 
144  // Messages from slaves.
151 
152  // Messages from both schedulers and slaves.
154 
159 
162 
165 
166  // Recovery counters.
168 
169  // Process metrics.
173 
174  // Successful registry operations.
181 
182  // Slave observer metrics.
183  //
184  // TODO(neilc): The `slave_shutdowns_xxx` metrics are deprecated and
185  // will always be zero. Remove in Mesos 2.0.
189 
193 
194  // Non-revocable resources.
195  std::vector<process::metrics::Gauge> resources_total;
196  std::vector<process::metrics::Gauge> resources_used;
197  std::vector<process::metrics::Gauge> resources_percent;
198 
199  // Revocable resources.
200  std::vector<process::metrics::Gauge> resources_revocable_total;
201  std::vector<process::metrics::Gauge> resources_revocable_used;
202  std::vector<process::metrics::Gauge> resources_revocable_percent;
203 
205  const TaskState& state,
206  const TaskStatus::Source& source,
207  const TaskStatus::Reason& reason);
208 };
209 
210 } // namespace master {
211 } // namespace internal {
212 } // namespace mesos {
213 
214 #endif // __MASTER_METRICS_HPP__
process::metrics::Counter messages_executor_to_framework
Definition: metrics.hpp:142
process::metrics::Counter messages_reregister_slave
Definition: metrics.hpp:146
process::metrics::Gauge slaves_disconnected
Definition: metrics.hpp:48
~Frameworks()
Definition: metrics.hpp:115
process::metrics::Gauge frameworks_active
Definition: metrics.hpp:55
process::metrics::Counter messages_reregister_framework
Definition: metrics.hpp:128
process::metrics::Counter recovery_slave_removals
Definition: metrics.hpp:167
process::metrics::Gauge event_queue_http_requests
Definition: metrics.hpp:172
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::Gauge event_queue_dispatches
Definition: metrics.hpp:171
process::metrics::Counter messages_reconcile_tasks
Definition: metrics.hpp:138
process::metrics::Gauge frameworks_inactive
Definition: metrics.hpp:56
process::metrics::Gauge tasks_unreachable
Definition: metrics.hpp:64
process::metrics::Counter messages_deactivate_framework
Definition: metrics.hpp:130
process::metrics::Gauge uptime_secs
Definition: metrics.hpp:44
process::metrics::Counter slave_unreachable_completed
Definition: metrics.hpp:191
process::metrics::Counter valid_status_updates
Definition: metrics.hpp:160
std::vector< process::metrics::Gauge > resources_used
Definition: metrics.hpp:196
process::metrics::Counter messages_update_slave
Definition: metrics.hpp:150
process::metrics::Gauge outstanding_offers
Definition: metrics.hpp:58
process::metrics::Gauge tasks_running
Definition: metrics.hpp:63
process::metrics::Counter slave_shutdowns_scheduled
Definition: metrics.hpp:186
void incrementTasksStates(const TaskState &state, const TaskStatus::Source &source, const TaskStatus::Reason &reason)
process::metrics::Gauge slaves_active
Definition: metrics.hpp:49
process::metrics::Counter messages_kill_task
Definition: metrics.hpp:131
process::metrics::Counter tasks_failed
Definition: metrics.hpp:67
process::metrics::Gauge event_queue_messages
Definition: metrics.hpp:170
process::metrics::Gauge slaves_connected
Definition: metrics.hpp:47
process::metrics::Counter valid_status_update_acknowledgements
Definition: metrics.hpp:163
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:176
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
process::metrics::Gauge tasks_killing
Definition: metrics.hpp:65
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:155
process::metrics::Counter messages_authenticate
Definition: metrics.hpp:153
process::metrics::Counter invalid_executor_to_framework_messages
Definition: metrics.hpp:158
process::metrics::Counter slave_unreachable_canceled
Definition: metrics.hpp:192
Definition: gauge.hpp:27
process::metrics::Counter tasks_error
Definition: metrics.hpp:70
std::vector< process::metrics::Gauge > resources_revocable_percent
Definition: metrics.hpp:202
process::metrics::Counter valid_executor_to_framework_messages
Definition: metrics.hpp:157
process::metrics::Gauge elected
Definition: metrics.hpp:45
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:190
process::metrics::Counter dropped_messages
Definition: metrics.hpp:82
std::vector< process::metrics::Gauge > resources_revocable_total
Definition: metrics.hpp:200
std::vector< process::metrics::Gauge > resources_total
Definition: metrics.hpp:195
process::metrics::Counter invalid_framework_to_executor_messages
Definition: metrics.hpp:156
process::metrics::Counter messages_suppress_offers
Definition: metrics.hpp:137
process::metrics::Counter slave_shutdowns_canceled
Definition: metrics.hpp:188
Metrics(const Master &master)
process::metrics::Gauge slaves_unreachable
Definition: metrics.hpp:51
process::metrics::Counter messages_status_update
Definition: metrics.hpp:148
process::metrics::Counter messages_revive_offers
Definition: metrics.hpp:136
process::metrics::Counter slave_removals
Definition: metrics.hpp:177
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:187
process::metrics::Counter messages_register_slave
Definition: metrics.hpp:145
process::metrics::Gauge frameworks_connected
Definition: metrics.hpp:53
process::metrics::Gauge frameworks_disconnected
Definition: metrics.hpp:54
process::metrics::Counter slave_removals_reason_unregistered
Definition: metrics.hpp:179
process::metrics::Counter messages_exited_executor
Definition: metrics.hpp:149
process::metrics::Counter messages_resource_request
Definition: metrics.hpp:133
process::metrics::Counter messages_framework_to_executor
Definition: metrics.hpp:139
hashmap< TaskState, SourcesReasons > tasks_states
Definition: metrics.hpp:79
process::metrics::Counter slave_removals_reason_registered
Definition: metrics.hpp:180
process::metrics::Counter messages_unregister_slave
Definition: metrics.hpp:147
process::metrics::Counter tasks_gone_by_operator
Definition: metrics.hpp:73
process::metrics::Gauge tasks_starting
Definition: metrics.hpp:62
process::metrics::Counter messages_decline_offers
Definition: metrics.hpp:135
process::metrics::Gauge tasks_staging
Definition: metrics.hpp:61
Definition: metrics.hpp:38
Frameworks(const std::string &principal)
Definition: metrics.hpp:107
process::metrics::Counter messages_unregister_framework
Definition: metrics.hpp:129
std::vector< process::metrics::Gauge > resources_revocable_used
Definition: metrics.hpp:201
process::metrics::Counter messages_received
Definition: metrics.hpp:97
std::vector< process::metrics::Gauge > resources_percent
Definition: metrics.hpp:197
process::metrics::Counter invalid_status_updates
Definition: metrics.hpp:161
process::metrics::Counter invalid_status_update_acknowledgements
Definition: metrics.hpp:164
Definition: master.hpp:392
process::metrics::Counter slave_removals_reason_unhealthy
Definition: metrics.hpp:178
process::metrics::Gauge slaves_inactive
Definition: metrics.hpp:50
hashmap< TaskStatus::Reason, process::metrics::Counter > Reasons
Definition: metrics.hpp:75
process::metrics::Counter slave_registrations
Definition: metrics.hpp:175
process::metrics::Counter tasks_dropped
Definition: metrics.hpp:71