---
title: "ezgh obs datasets sampling set"
description: "Replace a dataset's trace sampling policy from a JSON file."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh obs datasets sampling set

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh obs datasets sampling set <dataset> -f <policy.json> [--force] [flags]
```

Replace a dataset's trace sampling policy with a JSON file (-f - reads stdin):

```text
{ "enabled": true, "decisionWait": "30s",
  "rules": [ { "name": "errors", "when": { "status": "error" }, "keep": "all" } ],
  "default": { "percent": 5 } }
```

Rules are tried in order and the first that matches decides the whole trace; default decides when none does, and is required when enabled is true. A rule keeps "all", "none", &#123; "percent": p &#125; (0.01 to 100) or &#123; "perSecond": n &#125; (1 to 10,000). obs-api checks the policy and refuses one out of bounds, saying where. The file can be the output of `ezgh obs datasets sampling get -o json`: its policy is taken.

It's sent with the ETag ezgh reads just before: if someone changed the policy in between, nothing changes, and ezgh says so. A file from get -o json carries the version it was read at: when the policy has changed since (someone saved another version while you edited), ezgh refuses and changes nothing. `--force` sends no ETag, overwriting whatever is there.

Part of [`ezgh obs datasets sampling`](/cli/reference/obs-datasets-sampling).

## Examples

```sh
ezgh obs datasets sampling set production -f sampling.json
ezgh obs datasets sampling set staging -f - --force < sampling.json
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `-f`, `--file` | string |  | the policy's JSON file, or - for stdin |
| `--force` | boolean |  | send no ETag: overwrite the policy even if it changed since it was read |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/obs-datasets-sampling-set/index.mdx
