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_ALLOCATOR_MESOS_METRICS_HPP__
18 #define __MASTER_ALLOCATOR_MESOS_METRICS_HPP__
19 
20 #include <string>
21 #include <vector>
22 
23 #include <mesos/quota/quota.hpp>
24 
29 
30 #include <process/pid.hpp>
31 
32 #include <stout/hashmap.hpp>
33 
34 namespace mesos {
35 namespace internal {
36 namespace master {
37 namespace allocator {
38 namespace internal {
39 
40 // Forward declarations.
41 class HierarchicalAllocatorProcess;
42 
43 // Collection of metrics for the allocator; these begin
44 // with the following prefix: `allocator/mesos/`.
45 struct Metrics
46 {
48 
49  ~Metrics();
50 
51  void setQuota(const std::string& role, const Quota& quota);
52  void removeQuota(const std::string& role);
53 
54  void addRole(const std::string& role);
55  void removeRole(const std::string& role);
56 
58 
59  // Number of dispatch events currently waiting in the allocator process.
61 
62  // TODO(bbannier) This metric is identical to `event_queue_dispatches`, but
63  // uses a name deprecated in 1.0. This metric should be removed after the
64  // deprecation cycle.
66 
67  // Number of times the allocation algorithm has run.
69 
70  // Time spent in the allocation algorithm.
72 
73  // The latency of allocation runs due to the batching of allocation requests.
75 
76  // PullGauges for the total amount of each resource in the cluster.
77  std::vector<process::metrics::PullGauge> resources_total;
78 
79  // PullGauges for the allocated amount of each resource in the cluster.
80  std::vector<process::metrics::PullGauge> resources_offered_or_allocated;
81 
82  // PullGauges for the per-role quota allocation for each resource.
85 
86  // PullGauges for the per-role quota guarantee for each resource.
89 
90  // PullGauges for the per-role count of active offer filters.
92 };
93 
94 
96 {
97  explicit FrameworkMetrics(const FrameworkInfo& _frameworkInfo);
98 
100 
101  void reviveRole(const std::string& role);
102  void suppressRole(const std::string& role);
103 
104  // Since frameworks can update their list of roles,
105  // these methods add/remove per-role metrics.
106  void addSubscribedRole(const std::string& role);
107  void removeSubscribedRole(const std::string& role);
108 
109  const FrameworkInfo frameworkInfo;
110 
111  // Suppresion state metric (boolean 0 or 1) for each role.
113 };
114 
115 } // namespace internal {
116 } // namespace allocator {
117 } // namespace master {
118 } // namespace internal {
119 } // namespace mesos {
120 
121 #endif // __MASTER_ALLOCATOR_MESOS_METRICS_HPP__
const process::PID< HierarchicalAllocatorProcess > allocator
Definition: metrics.hpp:57
std::vector< process::metrics::PullGauge > resources_total
Definition: metrics.hpp:77
process::metrics::Counter allocation_runs
Definition: metrics.hpp:68
std::vector< process::metrics::PullGauge > resources_offered_or_allocated
Definition: metrics.hpp:80
Definition: master.hpp:27
process::metrics::Timer< Milliseconds > allocation_run_latency
Definition: metrics.hpp:74
hashmap< std::string, process::metrics::PullGauge > offer_filters_active
Definition: metrics.hpp:91
const FrameworkInfo frameworkInfo
Definition: metrics.hpp:109
Metrics(const HierarchicalAllocatorProcess &allocator)
Definition: counter.hpp:26
Definition: hashmap.hpp:38
Definition: quota.hpp:25
Definition: pull_gauge.hpp:46
hashmap< std::string, process::metrics::PushGauge > suppressed
Definition: metrics.hpp:112
hashmap< std::string, hashmap< std::string, process::metrics::PullGauge > > quota_allocated
Definition: metrics.hpp:84
Definition: spec.hpp:26
process::metrics::Timer< Milliseconds > allocation_run
Definition: metrics.hpp:71
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:279
Definition: attributes.hpp:24
process::metrics::PullGauge event_queue_dispatches
Definition: metrics.hpp:60
hashmap< std::string, hashmap< std::string, process::metrics::PullGauge > > quota_guarantee
Definition: metrics.hpp:88
void setQuota(const std::string &role, const Quota &quota)
process::metrics::PullGauge event_queue_dispatches_
Definition: metrics.hpp:65