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

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

Issue 2705273003: Roll infra_libs and gae_ts_mon in luci-py, and add field_specs to all metrics (Closed)
Patch Set: Rebase Created 3 years, 9 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('goats/teleported') 79 goats_teleported = ts_mon.CounterMetric(
80 'goats/teleported',
81 'Number of goats teleported',
82 None)
80 83
81 def get(self): 84 def get(self):
82 count = goat_teleporter.teleport() 85 count = goat_teleporter.teleport()
83 goats_teleported.increment(count) 86 goats_teleported.increment(count)
84 87
85 self.response.write('Teleported %d goats this time' % count) 88 self.response.write('Teleported %d goats this time' % count)
86 89
87 90
88 ## Appengine Modules 91 ## Appengine Modules
89 92
(...skipping 22 matching lines...) Expand all
112 115
113 from infra_libs import ts_mon 116 from infra_libs import ts_mon
114 117
115 # Override default target fields for app-global metrics. 118 # Override default target fields for app-global metrics.
116 TARGET_FIELDS = { 119 TARGET_FIELDS = {
117 'job_name': '', # module name 120 'job_name': '', # module name
118 'hostname': '', # version 121 'hostname': '', # version
119 'task_num': 0, # instance ID 122 'task_num': 0, # instance ID
120 } 123 }
121 124
122 remaining = ts_mon.GaugeMetric('goats/remaining') 125 remaining = ts_mon.GaugeMetric('goats/remaining', '...', None)
123 in_flight = ts_mon.GaugeMetric('goats/in_flight) 126 in_flight = ts_mon.GaugeMetric('goats/in_flight', '...', None)
124 127
125 def set_global_metrics(): 128 def set_global_metrics():
126 # Query some global resource, e.g. Datastore 129 # Query some global resource, e.g. Datastore
127 remaining.set(len(goats_to_teleport()), target_fields=TARGET_FIELDS) 130 remaining.set(len(goats_to_teleport()), target_fields=TARGET_FIELDS)
128 in_flight.set(len(goats_being_teleported()), target_fields=TARGET_FIELDS) 131 in_flight.set(len(goats_being_teleported()), target_fields=TARGET_FIELDS)
129 132
130 ts_mon.register_global_metrics([remaining, in_flight]) 133 ts_mon.register_global_metrics([remaining, in_flight])
131 ts_mon.register_global_metrics_callback('my callback', set_global_metrics) 134 ts_mon.register_global_metrics_callback('my callback', set_global_metrics)
132 135
133 The registered callback will be called at most once per minute, and 136 The registered callback will be called at most once per minute, and
134 only one instance will be running it at a time. A global metric is 137 only one instance will be running it at a time. A global metric is
135 then cleared the moment it is sent. Thus, global metrics will be sent 138 then cleared the moment it is sent. Thus, global metrics will be sent
136 at the correct intervals, regardless of the number of instances the 139 at the correct intervals, regardless of the number of instances the
137 app is currently running. 140 app is currently running.
138 141
139 Note also the use of `target_fields` parameter: it overrides the 142 Note also the use of `target_fields` parameter: it overrides the
140 default target fields which would otherwise distinguish the metric per 143 default target fields which would otherwise distinguish the metric per
141 module, version, or instance ID. Using `target_fields` in regular, 144 module, version, or instance ID. Using `target_fields` in regular,
142 "local" metrics is not allowed, as it would result in errors on the 145 "local" metrics is not allowed, as it would result in errors on the
143 monitoring endpoint, and loss of data. 146 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