---
title: "Set up logs forwarding for Public Cloud Databases"
description: "Forward logs of your Public Cloud database service to your Logs Data Platform data stream"
url: https://docs.ovhcloud.com/en/guides/public-cloud/databases/logs-to-customers
lang: en
lastUpdated: 2024-10-28
---
# Set up logs forwarding for Public Cloud Databases

## Objective

Public Cloud managed databases allow you to send logs of your service to your own Logs Data Platform (LDP) data stream.

**This guide explains how to forward service logs to your own LDP stream with the OVHcloud API.**

## Requirements

- A [Public Cloud database service](https://www.ovhcloud.com/fr/public-cloud/databases/) up and running
- Access to the [OVHcloud API](https://eu.api.ovh.com/console/)
- A Logs Data Platform account within this OVHcloud account with at least one destination stream configured
  - If you are not familiar with all the LDP _Stream_ configuration possibilities, simply create a new one with the default options (indexing & websocket enabled, long-term storage disabled) for the purpose of this guide.
- A running database service


***

### OVHcloud Control Panel Access

- **Direct link:** <ManagerLink to="/#/pci/projects">Public Cloud Projects</ManagerLink>
- **Navigation path:** <code className="action">Public Cloud</code> > Select your project

***


## Instructions

### Create your subscription


**Via the OVHcloud Control Panel**

On the database instance page, go to the <code className="action">Logs</code> section and click the <code className="action">Subscribe</code> button.
![LDP database subscription](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_subscription.png)Select the relevant LDP account by clicking the <code className="action">Subscribe</code> button.
![LDP database subscription 2](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_subscription2.png)The logs will then start to be forwarded to your LDP stream.


**Via the OVHcloud API**

1\. Retrieve the required information
**Retrieve your LDP destination `streamId`:**
Log in to the <ManagerLink to="/">OVHcloud Control Panel</ManagerLink>, go to the <code className="action">Identity, Security & Operations</code> section. In the left-hand menu, select <code className="action">Logs Data Platform</code> then click on the relevant LDP instance.
![LDP list page](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_page.png)Go to the <code className="action">Data stream</code> tab.
![LDP details page](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_page_details.png)Choose your target stream and click on <code className="action">Copy stream ID</code>.
**Retrieve your LDP destination `serviceName`:**
- This refers to your Public Cloud project ID. You can retrieve it in the Public Cloud section of your project.
![LDP project id](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_project_id.png)**Retrieve your `clusterId`:**
In the left-hand menu, click on <code className="action">Databases</code>, then choose the database instance you want to manage.
In the cluster details, you can find the `Service ID` field, which corresponds to the cluster ID.
![LDP database details](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_details.png)2\. Start by retrieving the types of logs available for your database cluster with the following API call:

🇪🇺EU▾

[GET/cloud/project/{serviceName}/database/{engine}/{clusterId}/log/kind](https://eu.api.ovh.com/console/?section=/cloud&branch=v1#get-/cloud/project/-serviceName-/database/-engine-/-clusterId-/log/kind)

This will return the list of valid kind values you can use when subscribing to logs.
3\. Once you know the valid kind, use it to subscribe to a log stream with this API call:

🇪🇺EU▾

[POST/cloud/project/{serviceName}/database/{engine}/{clusterId}/log/subscription](https://eu.api.ovh.com/console/?section=/cloud&branch=v1#post-/cloud/project/-serviceName-/database/-engine-/-clusterId-/log/subscription)

```console
    body : {
        kind: <log_type_from_previous_call>
        streamId: <your_stream_id>
    }
```
The logs will then start to be forwarded to your LDP stream.


### Find logs in Graylog

On the LDP page, click the `sample-data-stream
` button (the last data stream modified when you previously subscribed to it), or click the `Graylog
` button.
![LDP database go to graylog](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_go_to_graylogs.png)
You need to log in using your Graylog credentials. You can retrieve them from the LDP details page, in the `Configuration` section. The login corresponds to the value shown on the `Logs Data Platform service` line, and the password is displayed under `Password`.

![LDP database ldp details](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_ldp_details.png)
Once connected, you can view your service logs in your Graylog stream.

![LDP database graylogs result](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_graylogs_result.png)
You can also use the following Graylog queries for more granular filtering:

#### MongoDB

Query: `cluster: "<HostID>"`

You can find this `HostID` in your OVHcloud Control Panel:

- In `Login information` switch `Service` to `mongodb`
- Now you can see the `Host` field with the format `<HostID>.database.cloud.ovh.net`

#### Other Engines

Query: `clusterID: "<Engine>-<HostID>"`

You can find this `HostID` in your OVHcloud Control Panel:

- Find the Cluster ID formatted as a UUID (AAAAAAAA-BBBB-CCCC-DDDDDDDDDDDD)
- `HostID` is the first part of the UUID (AAAAAAAA)

### Delete subscription

You have 2 methods to delete a subscription:


**Via the OVHcloud Control Panel**

In the subscription page of the database instance, click the <code className="action">Unsubscribe</code> button.
![LDP database unsubscribe](/images/public-cloud/databases/databases-16-logs-to-customer/ldp_database_unsubscribe.png)

**Via the OVHcloud API**

- You can delete subscriptions using the `subscriptionId` concerned in this API call:

🇪🇺EU▾

[DELETE/cloud/project/{serviceName}/database/{engine}/{clusterId}/log/subscription/{subscriptionId}](https://eu.api.ovh.com/console/?section=/cloud&branch=v1#delete-/cloud/project/-serviceName-/database/-engine-/-clusterId-/log/subscription/-subscriptionId-)


- If you delete your database service, all subscriptions of this service are deleted automatically.

## We want your feedback!

We would love to help answer questions and appreciate any feedback you may have.

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://www.ovhcloud.com/fr/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

Are you on Discord? Connect to our channel at [https://discord.gg/ovhcloud](https://discord.gg/ovhcloud) and interact directly with the team that builds our databases service!
