Plugins 〉Google Cloud Logging
Google Cloud Logging
Google Cloud Logging Data Source
Overview
The Google Cloud Logging Data Source is a backend data source plugin for Grafana, which allows users to query and visualize their Google Cloud logs in Grafana.
Setup
Enable Cloud Resource Manager API
You need to enable the resource manager API. Otherwise, your cloud projects will not be displayed in the dropdown menu.
You can follow the steps to enable it:
- Navigate to the cloud resource manager API page in GCP and select your project
- Press the
Enable
button
Generate a JWT file & Assign IAM Permissions
- If you don't have gcp project, add a new gcp project. link
- Open the Credentials page in the Google API Console
- Click Create Credentials then click Service account
- On the Create service account page, enter the Service account details
- On the
Create service account
page, fill in theService account details
and then clickCreate and Continue
- On the
Grant this service account access to project
section, add theLogs Viewer
role andLogs View Accessor
role underLogging
to the service account. ClickDone
- In the next step, click the service account you just created. Under the
Keys
tab and selectAdd key
andCreate new key
- Choose key type
JSON
and clickCreate
. A JSON key file will be created and downloaded to your computer
If you want to access logs in multiple cloud projects, you need to ensure the service account has permission to read logs from all of them.
If you host Grafana on a GCE VM, you can also use the Compute Engine service account. You need to make sure the service account has sufficient permissions to access the scopes and logs in all projects.
Service account impersonation
You can also configure the plugin to use service account impersonation.
You need to ensure the service account used by this plugin has the iam.serviceAccounts.getAccessToken
permission. This permission is in roles like the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator). Also, the service account impersonated
by this plugin needs logging read and project list permissions.
Grafana Configuration
- With Grafana restarted, navigate to
Configuration -> Data sources
(or the route/datasources
) - Click "Add data source"
- Select "Google Cloud Logging"
- Provide credentials in a JWT file, either by using the file selector or pasting the contents of the file.
- Click "Save & test" to test that logs can be queried from Cloud Logging.
An alternative way to provision the data source
After the plugin is installed, you can define and configure the data source in YAML files as part of Grafana’s provisioning system, similar to the Google Cloud Monitoring plugin. For more information about provisioning, and for available configuration options, refer to Provisioning Grafana.
The following YAML is an example.
apiVersion: 1
datasources:
- name: Google Cloud Logging
type: googlecloud-logging-datasource
access: proxy
jsonData:
authenticationType: gce
Supported variables
The plugin currently supports variables for logging scopes. For example, you can define a project variable and switch between projects. The following screenshot shows an example using project, bucket, and view.
Below is an example of defining a variable for log views.
Alerting
Grafana Alerting is not directly supported due to how Logging Query Language works on Google Cloud. If you need to create alerts based on logs, consider using Log-based metrics and a Cloud Monitoring data source.
Licenses
Cloud Logging Logo (src/img/logo.svg
) is from Google Cloud's Official icons and sample diagrams
As commented, JWTForm
and JWTConfigEditor
are largely based on Apache-2.0 licensed grafana-google-sdk-react
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
.h4 . .mb-0 }
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Installing Google Cloud Logging on Grafana Cloud:
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
For more information, visit the docs on plugin installation.
Installing on a local Grafana:
For local instances, plugins are installed and updated via a simple CLI command. Plugins are not updated automatically, however you will be notified when updates are available right within your Grafana.
1. Install the Data Source
Use the grafana-cli tool to install Google Cloud Logging from the commandline:
grafana-cli plugins install
The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins. More information on the cli tool.
Alternatively, you can manually download the .zip file for your architecture below and unpack it into your grafana plugins directory.
Alternatively, you can manually download the .zip file and unpack it into your grafana plugins directory.
2. Configure the Data Source
Accessed from the Grafana main menu, newly installed data sources can be added immediately within the Data Sources section.
Next, click the Add data source button in the upper right. The data source will be available for selection in the Type select box.
To see a list of installed data sources, click the Plugins item in the main menu. Both core data sources and installed data sources will appear.
Changelog
1.4.1 (2024-03-22)
- Fix an encoding issue for parentheses
- Fix cloud logging link scope issue
- Add annotation support
- Update a few dependencies
1.4.0 (2023-09-26)
- Support service account impersonation
- Update README for alerting
1.3.0 (2023-07-12)
- Map default log level from debug to info
- Add trace info
- Correctly display protoPayload (#38)
- Support log scope variables (#32)
1.2.1 (2023-05-05)
- Support log scope (need roles/logging.viewAccessor)
- Fix httpRequest
1.2.0 (2023-03-17)
- Support GCE service account
- Support field-based filters in Explore page
- Interpolate variables in queries
- Correctly extract label/value pairs from structs
- Added a sample dashboard
1.1.1 (2023-02-03)
- Move hide logic to datasource.ts filter and reuse client for test connection
- Update dependencies in package.json
1.1.0 (2023-01-26)
- Adds Cloud Logging Service Endpoint to configuration
- Fixes hide not working for Cloud Logging query
- Fixes inability to retrieve projects displaying an error
1.0.0 (2023-01-17)
Initial release.