# Manage & Operate › Logs Data Platform › Data streams › Rules API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Manage & Operate product's sections: https://developers.eu.ovhcloud.com/reference/manage-operate/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 4 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/manage-operate/logs-data-platform/data-streams/rules/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/manage-operate/logs-data-platform/data-streams/rules.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/manage-operate/logs-data-platform/data-streams/rules.json?format=openapi3

## Operations

- `GET /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule` — List stream rules
- `GET /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}` — Get a stream rule
- `POST /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule` — Create a stream rule
- `DELETE /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}` — Delete a stream rule

## List stream rules

`GET /1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/logs-data-platform/data-streams/rules/#get-dbaas-logs-servicename-output-graylog-stream-streamid-rule

**Status:** Stable production version  
**IAM actions:** `ldp:apiovh:output/graylog/stream/rule/get`

Returns the stream rules of the Logs Data Platform service.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |
| `streamId` | path | string (uuid) | yes | Stream ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string (uuid)[] | successful operation |
| 404 | object | Error 404 response |

```json
[
  "00000000-0000-0000-0000-000000000000"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule");

print_r($result);
?>
```

## Get a stream rule

`GET /1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/logs-data-platform/data-streams/rules/#get-dbaas-logs-servicename-output-graylog-stream-streamid-rule-ruleid

**Status:** Stable production version  
**IAM actions:** `ldp:apiovh:output/graylog/stream/rule/get`

Returns the stream rule.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ruleId` | path | string (uuid) | yes | Rule ID |
| `serviceName` | path | string | yes | Service name |
| `streamId` | path | string (uuid) | yes | Stream ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | dbaas.logs.StreamRule | successful operation |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string | read-only | Field name |
| `isInverted` | boolean | read-only | Invert condition |
| `operator` | dbaas.logs.StreamRuleOperatorEnum | read-only | Field operator — one of `FIELD_PRESENCE`, `GREATER_THAN`, `MATCH_EXACTLY`, `SMALLER_THAN` |
| `ruleId` | string (uuid) | read-only | Stream rule ID |
| `value` | string | read-only | Field value |

```json
{
  "field": "string",
  "isInverted": true,
  "operator": "FIELD_PRESENCE",
  "ruleId": "00000000-0000-0000-0000-000000000000",
  "value": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}");

print_r($result);
?>
```

## Create a stream rule

`POST /1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/logs-data-platform/data-streams/rules/#post-dbaas-logs-servicename-output-graylog-stream-streamid-rule

**Status:** Stable production version  
**IAM actions:** `ldp:apiovh:output/graylog/stream/rule/create`

Creates a stream rule on the Logs Data Platform service.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |
| `streamId` | path | string (uuid) | yes | Stream ID |

### Request body (required)

Type: `dbaas.logs.OutputGraylogStreamRuleCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string | yes | Field name |
| `isInverted` | boolean |  | Invert condition |
| `operator` | dbaas.logs.StreamRuleOperatorEnum | yes | Field operator — one of `FIELD_PRESENCE`, `GREATER_THAN`, `MATCH_EXACTLY`, `SMALLER_THAN` |
| `value` | string | yes | Field value |

```json
{
  "field": "string",
  "isInverted": true,
  "operator": "FIELD_PRESENCE",
  "value": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | dbaas.logs.Operation | successful operation |
| 403 | object | Error 403 response |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `aliasId` | string (uuid) | read-only | Alias used |
| `createdAt` | string (date-time) | read-only | Operation creation |
| `dashboardId` | string (uuid) | read-only | Dashboard used |
| `encryptionKeyId` | string (uuid) | read-only | Encryption key used |
| `indexId` | string (uuid) | read-only | Index used |
| `inputId` | string (uuid) | read-only | Input used |
| `operationId` | string (uuid) | read-only | Operation ID |
| `osdId` | string (uuid) | read-only | OpenSearch Dashboards used |
| `roleId` | string (uuid) | read-only | Role used |
| `serviceName` | string | read-only | Service name |
| `state` | dbaas.logs.OperationStateEnum | read-only | Operation status — one of `FAILURE`, `PENDING`, `RECEIVED`, `RETRY`, `REVOKED`, `RUNNING`, `STARTED`, `SUCCESS` |
| `streamId` | string (uuid) | read-only | Stream used |
| `subscriptionId` | string (uuid) | read-only | Subscription used |
| `tenantId` | string (uuid) | read-only | Metrics tenant used |
| `tokenId` | string (uuid) | read-only | Token used |
| `updatedAt` | string (date-time) | read-only | Operation last update |

```json
{
  "aliasId": "00000000-0000-0000-0000-000000000000",
  "createdAt": "2024-01-01T12:00:00Z",
  "dashboardId": "00000000-0000-0000-0000-000000000000",
  "encryptionKeyId": "00000000-0000-0000-0000-000000000000",
  "indexId": "00000000-0000-0000-0000-000000000000",
  "inputId": "00000000-0000-0000-0000-000000000000",
  "operationId": "00000000-0000-0000-0000-000000000000",
  "osdId": "00000000-0000-0000-0000-000000000000",
  "roleId": "00000000-0000-0000-0000-000000000000",
  "serviceName": "string",
  "state": "FAILURE",
  "streamId": "00000000-0000-0000-0000-000000000000",
  "subscriptionId": "00000000-0000-0000-0000-000000000000",
  "tenantId": "00000000-0000-0000-0000-000000000000",
  "tokenId": "00000000-0000-0000-0000-000000000000",
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: dbaas.logs.OutputGraylogStreamRuleCreation
result = client.post("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule",
	field = None, # Field name (type: string)
	isInverted = None, # Invert condition (type: boolean, nullable)
	operator = None, # Field operator (type: dbaas.logs.StreamRuleOperatorEnum)
	value = None, # Field value (type: string)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: dbaas.logs.OutputGraylogStreamRuleCreation
$result = $ovh->post("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule", array(
	field => null, // Field name (type: string)
	isInverted => null, // Invert condition (type: boolean, nullable)
	operator => null, // Field operator (type: dbaas.logs.StreamRuleOperatorEnum)
	value => null, // Field value (type: string)
));

print_r($result);
?>
```

## Delete a stream rule

`DELETE /1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/logs-data-platform/data-streams/rules/#delete-dbaas-logs-servicename-output-graylog-stream-streamid-rule-ruleid

**Status:** Stable production version  
**IAM actions:** `ldp:apiovh:output/graylog/stream/rule/delete`

Deletes the stream rule.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ruleId` | path | string (uuid) | yes | Rule ID |
| `serviceName` | path | string | yes | Service name |
| `streamId` | path | string (uuid) | yes | Stream ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | dbaas.logs.Operation | successful operation |
| 403 | object | Error 403 response |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `aliasId` | string (uuid) | read-only | Alias used |
| `createdAt` | string (date-time) | read-only | Operation creation |
| `dashboardId` | string (uuid) | read-only | Dashboard used |
| `encryptionKeyId` | string (uuid) | read-only | Encryption key used |
| `indexId` | string (uuid) | read-only | Index used |
| `inputId` | string (uuid) | read-only | Input used |
| `operationId` | string (uuid) | read-only | Operation ID |
| `osdId` | string (uuid) | read-only | OpenSearch Dashboards used |
| `roleId` | string (uuid) | read-only | Role used |
| `serviceName` | string | read-only | Service name |
| `state` | dbaas.logs.OperationStateEnum | read-only | Operation status — one of `FAILURE`, `PENDING`, `RECEIVED`, `RETRY`, `REVOKED`, `RUNNING`, `STARTED`, `SUCCESS` |
| `streamId` | string (uuid) | read-only | Stream used |
| `subscriptionId` | string (uuid) | read-only | Subscription used |
| `tenantId` | string (uuid) | read-only | Metrics tenant used |
| `tokenId` | string (uuid) | read-only | Token used |
| `updatedAt` | string (date-time) | read-only | Operation last update |

```json
{
  "aliasId": "00000000-0000-0000-0000-000000000000",
  "createdAt": "2024-01-01T12:00:00Z",
  "dashboardId": "00000000-0000-0000-0000-000000000000",
  "encryptionKeyId": "00000000-0000-0000-0000-000000000000",
  "indexId": "00000000-0000-0000-0000-000000000000",
  "inputId": "00000000-0000-0000-0000-000000000000",
  "operationId": "00000000-0000-0000-0000-000000000000",
  "osdId": "00000000-0000-0000-0000-000000000000",
  "roleId": "00000000-0000-0000-0000-000000000000",
  "serviceName": "string",
  "state": "FAILURE",
  "streamId": "00000000-0000-0000-0000-000000000000",
  "subscriptionId": "00000000-0000-0000-0000-000000000000",
  "tenantId": "00000000-0000-0000-0000-000000000000",
  "tokenId": "00000000-0000-0000-0000-000000000000",
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}/rule/{ruleId}");

print_r($result);
?>
```
