StackDriver
Google Cloud's Operations Suite (formerly known as Stackdriver) provides a robust monitoring and management platform for applications and services running on Google Cloud, AWS, and on-premises environments. The Metrics feature focuses on collecting and analyzing time-series data to monitor system performance, resource utilization, and application health.
Configure Martini Runtime to send Metrics to StackDriver
This guide helps you configure Martini Runtime to send metrics to StackDriver, facilitating the monitoring of your application's performance. If you encounter any issues, refer to the Google Cloud/StackDriver documentation or seek support from the Google Cloud community.
Google Setup
- Setup a Billing Google Cloud Account. This is required to be able to use StackDriver and Metrics.
- Create a Google Project or use the premade "My First Project" that comes with the Google account to explore the Google Console.
-
Since your application runs locally, you'll need to create a service account and grant it the necessary permissions to send metrics to Stackdriver.
Create a service account:
- Go to the IAM & Admin section by clicking "Project Settings" then select Service Accounts from the left side menu.
- Click "Create Service Account". Give your service account a descriptive name then click "Create" and "Continue".
- Add the Monitoring Metric Writer role then click "Continue".
- Skip the third optional step then click "Done".
-
Get and add credentials to your environment.
- In the Service Account page, click on "Keys".
- Click on "Add Key" and create a new key.
- In the dialog box that appears, select JSON key type and click "Create". This will download the JSON key file into your computer.
-
Set your Google Credential environment variable to the path of your downloaded private key JSON file. In your terminal, run the following command:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
Configuring Martini Runtime
- Import the Micrometer Registry Stackdriver JAR file on Martini.
-
Configure the
application.properties
with the following properties:1 2 3 4 5 6 7 8 9 10 11 12
# Enable Stackdriver metrics exporting management.metrics.export.stackdriver.enabled=true # Specify your Google Cloud Project ID management.metrics.export.stackdriver.project-id=<google-project-id> # Set the export interval to at least 1 minute to avoid issues # For more details, see: https://github.com/micrometer-metrics/micrometer/issues/1268 management.metrics.export.stackdriver.step=1m # Set specific batch size for exporting metrics to avoid issue mentioned above management.metrics.export.stackdriver.batch-size=20
-
Restart Martini Runtime to apply the changes.
Query Metrics
- Click on Navigation Menu icon on the left and click "View All Products".
- In the "All Products" page, look for Monitoring under Observability.
- To query a specific metric, you may select Metrics explorer.
- To find the metrics sent by Martini Runtime, go to Select a Metric > Global > Custom metrics, then select a metric there.