SAP HANA monitoring agent user guide

Google Cloud provides a custom monitoring agent that collects custom metrics from SAP HANA and sends them to Cloud Monitoring, a monitoring solution built into Google Cloud. With Cloud Monitoring, you can build out dashboards to visualize your SAP HANA metrics and set up alerts based on metric thresholds. For more information, see the Cloud Monitoring documentation.

Prerequisites

This guide assumes that you have deployed SAP HANA on Google Cloud using the method described in the SAP HANA Deployment Guide.

Setting up Cloud Monitoring for your project

To use the Google monitoring agent for SAP HANA, you must set up a new Workspace that is connected to your Google Cloud project. The following steps create a new Workspace:

  1. In your browser, go to Cloud Monitoring:

    Go to Cloud Monitoring

  2. Click Add Workspace.

  3. On the Create your free Workspace page, click the Google Cloud project field. A drop-down menu containing your Google Cloud projects appears.

  4. Select your project from the menu and click Create Account.

  5. On the Add Google Cloud projects to monitor page, click Continue.

  6. On the Monitor AWS accounts page, click Skip AWS Setup.

  7. On the Install the Monitoring Agents page, click Continue.

  8. On the Get Reports by Email page, select No reports and then click Continue.

  9. After the message "Finished initial collection!" appears, click Launch monitoring to enter your Workspace dashboard.

  10. Click Continue with the trial to finish setup.

You now have a Workspace monitoring your Google Cloud project, and the monitoring agent can send metrics to Monitoring.

Setting the required IAM roles

By default, the monitoring agent uses your Compute Engine virtual machine (VM) instance's default service account. This service account allows binaries running on the VM instance to write metrics to Monitoring.

If you choose to use a different service account, you must manually add the IAM role that provides these permissions to your service account.

To add the required IAM role to your service account:

  1. Go to the IAM & Admin page in the Cloud Console.

    Go to the IAM & Admin page

  2. Select your project and click Continue.

  3. Identify the service account to which you want to add a role.

    • If the service account isn't already on the members list, it doesn't have any roles assigned to it. Click Add member and enter the email address of the service account.
    • If the service account is already on the members list, it has existing roles. Click the current role dropdown list for the service account that you want to edit.
  4. Select Monitoring > Monitoring Metric Writer from the list of available roles.

  5. Click Add or Save to apply the roles to the service account.

Installing the agent

Choosing a deployment location

The monitoring agent can be run directly on one or more nodes in your SAP HANA installation, or indirectly as a service on another VM instance. Choose your deployment location based on your use case.

Downloading and installing the agent

To download and install the agent:

  1. Establish an SSH connection with your SAP HANA VM instance.
  2. Download and run the installation script:

    sudo curl https://storage.googleapis.com/gcm-ext/gcm_install.sh | bash -x
    When you run the preceding command, the installation script performs the following operations:

  3. Creates the following directories:

    • /usr/local/lib/gcm, which will contain the agent binary.
    • /etc/gcm.d, which will contain the queries you want the agent to run.
    • /var/spool/gcm, which contains the metrics that have recently been gathered by the agent. The agent eventually sends these metrics to Cloud Monitoring. After metrics are sent, they are deleted from /var/spool/gcm.
  4. Downloads the latest release of the agent and saves it to /usr/local/lib/gcm/.

  5. Creates a symlink to the binary in /usr/local/bin/gcm.

  6. Creates a basic configuration template, /etc/default/gcm.

  7. Creates a daemon configuration file, /etc/systemd/system/gcm.service.

  8. Reloads the systemd service definitions.

  9. Enables the monitoring agent as a daemon.

Updating the agent

When a new version is available, you update the agent manually.

Checking for a new version of the agent

  1. Check the version of your agent:

    gcm --version
  2. Check if an update is available:

    curl https://storage.googleapis.com/gcm-ext/LATEST

Downloading and updating the agent

To update the agent when a new version is available, follow these steps:

  1. Stop the agent process:

    sudo systemctl stop gcm
  2. Update the agent with the following command. The -C and -U options skip the creation of the default configuration file and Linux systemd service definition for the agent:

    sudo curl https://storage.googleapis.com/gcm-ext/gcm_install.sh | bash -s -- -C -U

  3. Start the agent:

    sudo systemctl start gcm

Configuring the agent

After running the install script, configure the VM instances that the agent will monitor and, optionally, the queries that the agent will perform on your database.

Defining the configuration file

When you ran the installation script, it created a configuration template file at the following location:

/etc/default/gcm

Using the configuration file, you can configure the agent to query SAP HANA on one or more VM instances. For each VM instance you want to monitor:

  1. Add a VM instance definition in the configuration file under instances. For each instance, define the name, host, port, user, and password.
  2. To enable the agent to collect metrics from that VM instance, add the VM instance name under enabled_instances.

Define the attributes in the configuration by using the following format:

---
config:
  timestamps_in_output: no
  debug_messages: yes
  skip_default_queries: yes
  queries_directory: /etc/gcm.d
  spool_directory: /var/spool/gcm
  enabled_instances:
    - [INSTANCE_NAME]
    - [INSTANCE_NAME_2]
  project_id: [PROJECT_ID]
  instances:
    - name: [INSTANCE_NAME]
      host: [INSTANCE_IP]
      port: [PORT_NUMBER]
      user: [DB_USERNAME]
      password: [YOUR_PASSWORD]
      type: [INSTANCE_TYPE]
    - name: [INSTANCE_NAME_2]
      host: [INSTANCE_IP_2]
      ...

The following attributes are required in the configuration file:

  • [PROJECT_ID]: The ID of the Google Cloud project that contains the VM instances to be monitored. Specify only one project ID.
  • [INSTANCE_NAME]: The name of the Compute Engine VM instance you want to monitor.
  • [INSTANCE_IP]: The internal or external IP of the Compute Engine VM instance you want to monitor. We recommend using internal IPs if possible, because they require less setup than external IPs and are private and secure by default.
  • [DB_USERNAME]: The SAP HANA database user that you want to use.
  • [PORT_NUMBER]: The port number of your SAP HANA database. Usually, the port number is 39015 for SAP HANA Express or 30015 for SAP HANA Platform Edition.
  • [YOUR_PASSWORD]: The user password for your database user.
  • [INSTANCE_TYPE]: Enter sap_hana for this field.

Optionally, you can configure the agent using the following flags. These parameters flags must be set before the config item:

  • timestamps_in_output (boolean). If you're running the agent as a daemon under systemd, set this to no, as systemd provides timestamps. Default value is no.
  • debug_messages (boolean): If set, show debug messages. Default value is yes.
  • skip_default_queries (boolean): Skips the default set of queries. Does not affect user-defined queries. Default value is no.
  • queries_directory (string): The directory in which to look for user-defined queries. Default value is /etc/gcm.d.
  • spool_directory (string): The directory in which to collect spooled metrics. Default value is /var/spool/gcm.

Defining custom queries

By default, the agent gathers a default set of metrics from your SAP HANA database. For descriptions of these metrics, as well as the queries that generate the metrics, see SAP HANA Default Metrics.

You can add additional queries by creating one or more custom YAML files in the following directory:

/etc/gcm.d

The following is an example query file:

- root: by_component
  type: sap_hana
  description: |
      Amount of memory (in MiB) used by service components
  query: |
    SELECT
             HOST AS "host",
             COMPONENT AS "component",
             SUM(USED_MEMORY_SIZE)/1024/1024 AS "mem_used_mb"
        FROM M_SERVICE_COMPONENT_MEMORY
    GROUP BY HOST, COMPONENT;
  columns:
    - type: LABEL
      value_type: STRING
      name: host
    - type: LABEL
      value_type: STRING
      name: component
    - type: GAUGE
      description: Amount of memory (in MiB) used by the service component
      value_type: DOUBLE
      name: mem_used_mb

Each YAML file comprises one or more items that represent the results of a given SQL query into your SAP HANA database's metrics. Each item has the following attributes:

  • root: A descriptive namespace for a given group of metrics.
  • query: The SQL query.
  • columns: The data type, value type, and column name for each field in the query.

    • type: Describes how the data is reported to Monitoring. You can set type to LABEL, which indicates that the type is a column head, or toGAUGE, one of the metric types defined in the Monitoring API's MetricKind enum. Currently, GAUGE is the only metric type supported by the agent.
    • value_type: The value type of the metric. The value of this parameter can be any of the value types defined in the Monitoring API's ValueType enum.
    • name: The name of the column.

For a full list of the system views that SAP HANA makes available for querying, see the SAP HANA SQL and System Views Reference.

Query results are limited to 1,000 records. Use SQL aggregate functions like SUM, AVG, COUNT, MIN and MAX to limit the number of records returned.

Performing basic operations

This section describes how to perform basic operations with the SAP HANA monitoring agent. For a full list of configurable options, run gcm --help.

Managing the monitoring agent daemon

When you ran the installation script, the installer created a systemd unit file for the agent, allowing you to manage the agent using standard systemctl commands. The following commands start, stop, and poll the status of the agent, respectively:

sudo systemctl start gcm
sudo systemctl stop gcm
sudo systemctl status gcm

To read the logs generated by systemctl, query the contents of the systemd journal by using the following command:

sudo journalctl -u gcm

To see the last few lines that were logged, you can add the -f flag, which functions like a pipe to tail -f:

sudo journalctl -u gcm -f

Suppressing default queries

By default, the agent runs its default queries in addition to any custom queries you've defined. You can disable this default set of queries by setting the skip_default_queries flag to yes in your config file, or by setting the --no-defaults flag when running the tool manually. For more information, see Defining the configuration file.

Manually collecting and sending metrics

To verify that the agent works as expected, you can manually run commands to run your queries, collect the resulting metrics, and then send them to Cloud Monitoring. To run your queries and collect the resulting metrics exactly once, run the following command:

sudo gcm gather

This command also sends your collected metrics to Cloud Monitoring.

Viewing your metrics in Cloud Monitoring

To display the metrics collected by Cloud Monitoring in your own charts and dashboards:

  1. In the Cloud Console, go to the Monitoring page.

    Go to Monitoring

  2. Select Dashboards > Create Dashboard.

  3. Click Add Chart.

  4. In the Resource Type menu, select Custom Metrics.

  5. In the Metric menu, select by_component/mem_used_mb. Leave the other fields with their default values. You see the chart data in the Preview section of the panel.

  6. Click Save.

You now have a simple dashboard displaying live metrics from your SAP HANA VM instance or instances.

Troubleshooting

Default queries are failing

Make sure that your SAP HANA database user has access to the following SAP HANA system views:

  • M_CS_ALL_COLUMNS
  • M_CS_TABLES
  • M_EXPENSIVE_STATEMENTS
  • M_HOST_RESOURCE_UTILIZATION
  • M_SERVICE_COMPONENT_MEMORY
  • M_SERVICE_MEMORY

Metrics are not being sent to Cloud Monitoring

Make sure that your Google Cloud service account has permission to write metrics to Cloud Monitoring. For details, see Setting the required IAM roles.

Support

For issues with Google Cloud infrastructure or services, contact Google Cloud Support. You can find contact information on the Support Overview page in the Google Cloud Console. If Google Cloud Support determines that a problem resides in your SAP systems, you are referred to SAP Support.

For SAP product-related issues, log your support request with SAP support. SAP evaluates the support ticket and, if it appears to be a Google Cloud infrastructure issue, transfers the ticket to the Google Cloud component BC-OP-LNX-GOOGLE or BC-OP-NT-GOOGLE.

Support requirements

Before you can receive support for SAP systems and the Google Cloud infrastructure and services that they use, you must meet the minimum support plan requirements.

For more information about the minimum support requirements for SAP on Google Cloud, see:

What's next