| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 [...] | 26 [...] |
| 27 | 27 |
| 28 app = webapp2.WSGIApplication(my_handlers) | 28 app = webapp2.WSGIApplication(my_handlers) |
| 29 gae_ts_mon.initialize(app, cron_module='<cron_module_name>') | 29 gae_ts_mon.initialize(app, cron_module='<cron_module_name>') |
| 30 | 30 |
| 31 You must do this in every top-level request handler that's listed in your | 31 You must do this in every top-level request handler that's listed in your |
| 32 app.yaml to ensure metrics are registered no matter which type of request | 32 app.yaml to ensure metrics are registered no matter which type of request |
| 33 an instance receives first. | 33 an instance receives first. |
| 34 | 34 |
| 35 If your app does not contain a `webapp2.WSGIApplication` instance | |
| 36 (e.g. it's a Cloud Endpoints only app), then pass `None` as the | |
| 37 first argument to `gae_ts_mon.initialize`. | |
| 38 | |
| 39 The `gae_ts_mon.initialize` method takes a few optional parameters: | 35 The `gae_ts_mon.initialize` method takes a few optional parameters: |
| 40 - `cron_module` (str, default='default'): if you specified a custom | 36 - `cron_module` (str, default='default'): if you specified a custom |
| 41 module for the cron job, you must specify it in every call to | 37 module for the cron job, you must specify it in every call to |
| 42 `initialize`. | 38 `initialize`. |
| 43 - `is_enabled_fn` (function with no arguments returning `bool`): | 39 - `is_enabled_fn` (function with no arguments returning `bool`): |
| 44 a callback to enable/disable sending the actual metrics. Default: `None` | 40 a callback to enable/disable sending the actual metrics. Default: `None` |
| 45 which is equivalent to `lambda: True`. The callback is called on every | 41 which is equivalent to `lambda: True`. The callback is called on every |
| 46 metrics flush, and takes effect immediately. Make sure the callback is | 42 metrics flush, and takes effect immediately. Make sure the callback is |
| 47 efficient, or it will slow down your requests. | 43 efficient, or it will slow down your requests. |
| 48 | 44 |
| 49 1. Instrument all Cloud Endpoint methods if you have any by adding a decorator: | |
| 50 | |
| 51 @gae_ts_mon.instrument_endpoint() | |
| 52 @endpoints.method(...) | |
| 53 def your_method(self, request): | |
| 54 ... | |
| 55 | |
| 56 1. Give your app's service account permission to send metrics to the API. You | 45 1. Give your app's service account permission to send metrics to the API. You |
| 57 can find the name of your service account on the `Permissions` page of your | 46 can find the name of your service account on the `Permissions` page of your |
| 58 project in the cloud console - it'll look something like | 47 project in the cloud console - it'll look something like |
| 59 `app-id@appspot.gserviceaccount.com`. Or search the default module's logs | 48 `app-id@appspot.gserviceaccount.com`. Or search the default module's logs |
| 60 for `"Initializing with service account"`. Add it as a "Publisher" of the | 49 for `"Initializing with service account"`. Add it as a "Publisher" of the |
| 61 "monacq" PubSub topic in the | 50 "monacq" PubSub topic in the |
| 62 [chrome-infra-mon-pubsub project](https://pantheon.corp.google.com/project/c
hrome-infra-mon-pubsub/cloudpubsub/topicList) | 51 [chrome-infra-mon-pubsub project](https://pantheon.corp.google.com/project/c
hrome-infra-mon-pubsub/cloudpubsub/topicList) |
| 63 by selecting it from the list and clicking "Permissions". If you see an | 52 by selecting it from the list and clicking "Permissions". If you see an |
| 64 error "You do not have viewing permissions for the selected resource.", then | 53 error "You do not have viewing permissions for the selected resource.", then |
| 65 please ask pgervais@chromium.org (AMER) or sergiyb@chromium.org (EMEA) to do | 54 please ask pgervais@chromium.org (AMER) or sergiyb@chromium.org (EMEA) to do |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 only one instance will be running it at a time. A global metric is | 123 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 | 124 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 | 125 at the correct intervals, regardless of the number of instances the |
| 137 app is currently running. | 126 app is currently running. |
| 138 | 127 |
| 139 Note also the use of `target_fields` parameter: it overrides the | 128 Note also the use of `target_fields` parameter: it overrides the |
| 140 default target fields which would otherwise distinguish the metric per | 129 default target fields which would otherwise distinguish the metric per |
| 141 module, version, or instance ID. Using `target_fields` in regular, | 130 module, version, or instance ID. Using `target_fields` in regular, |
| 142 "local" metrics is not allowed, as it would result in errors on the | 131 "local" metrics is not allowed, as it would result in errors on the |
| 143 monitoring endpoint, and loss of data. | 132 monitoring endpoint, and loss of data. |
| OLD | NEW |