Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: appengine/third_party/gae_ts_mon/README.md

Issue 2708113002: Revert of Add field_specs to all metrics in luci-py (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/ts_mon_metrics.py ('k') | appengine/third_party/gae_ts_mon/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Setting up timeseries monitoring on App Engine. 1 # Setting up timeseries monitoring on App Engine.
2 2
3 1. Symlink this directory into your appengine app. 3 1. Symlink this directory into your appengine app.
4 4
5 cd infra/appengine/myapp 5 cd infra/appengine/myapp
6 ln -s ../../appengine_module/gae_ts_mon . 6 ln -s ../../appengine_module/gae_ts_mon .
7 7
8 1. Add the scheduled task to your `cron.yaml` file. Create it if you don't 8 1. Add the scheduled task to your `cron.yaml` file. Create it if you don't
9 have one already. 9 have one already.
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 it's not enabled already. 69 it's not enabled already.
70 70
71 You're done! You can now use ts_mon metrics exactly as you normally would using 71 You're done! You can now use ts_mon metrics exactly as you normally would using
72 the infra_libs.ts_mon module. Here's a quick example, but see the 72 the infra_libs.ts_mon module. Here's a quick example, but see the
73 [timeseries monitoring docs](https://chrome-internal.googlesource.com/infra/infr a_internal/+/master/doc/ts_mon.md) 73 [timeseries monitoring docs](https://chrome-internal.googlesource.com/infra/infr a_internal/+/master/doc/ts_mon.md)
74 for more information. 74 for more information.
75 75
76 from infra_libs import ts_mon 76 from infra_libs import ts_mon
77 77
78 class MyHandler(webapp2.RequestHandler): 78 class MyHandler(webapp2.RequestHandler):
79 goats_teleported = ts_mon.CounterMetric( 79 goats_teleported = ts_mon.CounterMetric('goats/teleported')
80 'goats/teleported',
81 'Number of goats teleported',
82 None)
83 80
84 def get(self): 81 def get(self):
85 count = goat_teleporter.teleport() 82 count = goat_teleporter.teleport()
86 goats_teleported.increment(count) 83 goats_teleported.increment(count)
87 84
88 self.response.write('Teleported %d goats this time' % count) 85 self.response.write('Teleported %d goats this time' % count)
89 86
90 87
91 ## Appengine Modules 88 ## Appengine Modules
92 89
(...skipping 22 matching lines...) Expand all
115 112
116 from infra_libs import ts_mon 113 from infra_libs import ts_mon
117 114
118 # Override default target fields for app-global metrics. 115 # Override default target fields for app-global metrics.
119 TARGET_FIELDS = { 116 TARGET_FIELDS = {
120 'job_name': '', # module name 117 'job_name': '', # module name
121 'hostname': '', # version 118 'hostname': '', # version
122 'task_num': 0, # instance ID 119 'task_num': 0, # instance ID
123 } 120 }
124 121
125 remaining = ts_mon.GaugeMetric('goats/remaining', '...', None) 122 remaining = ts_mon.GaugeMetric('goats/remaining')
126 in_flight = ts_mon.GaugeMetric('goats/in_flight', '...', None) 123 in_flight = ts_mon.GaugeMetric('goats/in_flight)
127 124
128 def set_global_metrics(): 125 def set_global_metrics():
129 # Query some global resource, e.g. Datastore 126 # Query some global resource, e.g. Datastore
130 remaining.set(len(goats_to_teleport()), target_fields=TARGET_FIELDS) 127 remaining.set(len(goats_to_teleport()), target_fields=TARGET_FIELDS)
131 in_flight.set(len(goats_being_teleported()), target_fields=TARGET_FIELDS) 128 in_flight.set(len(goats_being_teleported()), target_fields=TARGET_FIELDS)
132 129
133 ts_mon.register_global_metrics([remaining, in_flight]) 130 ts_mon.register_global_metrics([remaining, in_flight])
134 ts_mon.register_global_metrics_callback('my callback', set_global_metrics) 131 ts_mon.register_global_metrics_callback('my callback', set_global_metrics)
135 132
136 The registered callback will be called at most once per minute, and 133 The registered callback will be called at most once per minute, and
137 only one instance will be running it at a time. A global metric is 134 only one instance will be running it at a time. A global metric is
138 then cleared the moment it is sent. Thus, global metrics will be sent 135 then cleared the moment it is sent. Thus, global metrics will be sent
139 at the correct intervals, regardless of the number of instances the 136 at the correct intervals, regardless of the number of instances the
140 app is currently running. 137 app is currently running.
141 138
142 Note also the use of `target_fields` parameter: it overrides the 139 Note also the use of `target_fields` parameter: it overrides the
143 default target fields which would otherwise distinguish the metric per 140 default target fields which would otherwise distinguish the metric per
144 module, version, or instance ID. Using `target_fields` in regular, 141 module, version, or instance ID. Using `target_fields` in regular,
145 "local" metrics is not allowed, as it would result in errors on the 142 "local" metrics is not allowed, as it would result in errors on the
146 monitoring endpoint, and loss of data. 143 monitoring endpoint, and loss of data.
OLDNEW
« no previous file with comments | « appengine/swarming/ts_mon_metrics.py ('k') | appengine/third_party/gae_ts_mon/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698