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

# Metric shaping rules

Observability Platform applies shaping rules at different phases along the data
journey. Drop rules are applied at ingestion time. After metrics are sent but before
they're stored, rollup rules and mapping rules are applied. Derived metrics and
recording rules are then applied at query time.

```mermaid actions={false} theme={null}
flowchart TB
 subgraph OP["Observability Platform"]
   subgraph Ingest["Ingestion"]
     Drop["Drop<br>rules"]
   end
   subgraph Aggregate["Aggregation"]
     Rollup["Rollup<br>rules"]
     Mapping["Mapping<br>rules"]
   end
   subgraph Query["Querying"]
     Derived["Derived<br>metrics"]
     Record["Recording<br>rules"]
   end
 end
 Ingest --> Aggregate --> Query

click Drop "/control/shaping/shape-metrics/rules/drop-rules"
click Rollup "/control/shaping/shape-metrics/rules/rollup"
click Mapping "/control/shaping/shape-metrics/rules/mapping"
click Derived "/investigate/querying/metrics/derived-telemetry/derived-metrics"
click Record "/control/shaping/shape-metrics/rules/recording"

classDef rules fill:#2fbf71,stroke-width:2px,stroke:#2fbf71,color:#FFFFFF,font-weight:underline;
class Drop,Rollup,Mapping,Derived,Record rules
```

## Reduce stored metrics

Chronosphere Observability Platform [ingests](/ingest) metrics from many sources.
These sources can supply multiple [metric types](/control/shaping/shape-metrics/types), which are
generally ingested as raw data.

Although raw data might provide detailed information about a specific point in time,
that data grows rapidly and is expensive to store. Use the following shaping rules to
control costs by aggregating, downsampling, or dropping unneeded metric data:

* [Drop rules](/control/shaping/shape-metrics/rules/drop-rules) reduce incoming data or cardinality
  to pare down your stored metrics across both time and labels. Use drop rules to omit
  incoming metrics based on labels, and only retain
  the metrics you need. These rules help reduce persisted data, and you can
  implement them quickly.

* [Rollup rules](/control/shaping/shape-metrics/rules/rollup) downsample and aggregate metrics
  after they're sent by the client but before they're stored. Use rollup rules to
  reduce cardinality, downsample data, and perform basic aggregations across both
  time and labels. These rules are scalable, can drop raw data, and handle
  late-arriving data.

* [Mapping rules](/control/shaping/shape-metrics/rules/mapping) downsample in-memory metric data on
  the streaming ingest path and then store any results in the database, which happens
  before metric aggregation. Use mapping rules to reduce stored metrics across time
  only.

* [Recommendations](/control/shaping/shape-metrics/reduce-cardinality/recommendations) identify
  metrics and labels with no usage or utility over the past 30 days. Apply the
  suggested recommendations to reduce the impact on persisted writes and persisted
  cardinality.

When ingesting Google Cloud metrics, use
[filters and aggregations](/ingest/metrics-traces/gcp#control-incoming-metrics) to
reduce incoming metrics.

Review your metrics to determine if they're actionable because they have
[*references*](/investigate/analyze/usage#summary), or because some of their labels
have high utility (*dimensions*).

See [Reducing cardinality](/control/shaping/shape-metrics/reduce-cardinality) for more information
about this process.

```mermaid actions={false} theme={null}
graph LR
accTitle: What kind of rule should I use?
accDescr: A flowchart to help with the process of finding metrics to remove.
Profile[Profile<br>metrics<br>to triage]-->Ref@{shape: diamond, label: "Are there<br>references?"}
Ref -->|Yes| Unused@{shape: diamond, label: "Are there<br>unused<br>dimensions?"}
Ref -->|No| Drop[Drop the metric]
Unused -->|Yes| Rollup[Use rollup<br>rules to drop<br>dimensions]
Unused -->|No| Value@{shape: diamond, label: "Do the<br>dimensions<br>provide value?"}
Value --> |Yes| Next[Find next<br>metric]
Value -->|No| Rollup

click Profile "/investigate/analyze/telemetry-analyzer"
click Drop "/control/shaping/shape-metrics/rules/drop-rules"
click Rollup "/control/shaping/shape-metrics/rules/rollup"

classDef rules fill:#2fbf71,stroke-width:2px,stroke:#2fbf71,color:#FFFFFF,font-weight:bold;
class Profile,Drop,Rollup rules
```

## Optimize query performance

<Note>
  Although Observability Platform provides recording rules to optimize query performance,
  Chronosphere recommends using [rollup rules](/control/shaping/shape-metrics/rules/rollup) in most
  cases because they can reduce both cardinality and the volume of the data you persist.
</Note>

[Recording rules](/control/shaping/shape-metrics/rules/recording) primarily improve query
performance. You can execute any PromQL query and add labels, which make queries more
efficient. However, recording rules impact your persisted data. If you want to change
how data is presented to make it easier for users to query, consider using [alias
expressions](#alias-expressions), which don't impact persisted data.

If you experience issues with [late-arriving data](/control/storage), consider using
[rollup rules](/control/shaping/shape-metrics/rules/rollup) instead, since recording rules might
impact short-term query results.

You can also use rollup rules and drop rules to
[fix slow queries](/investigate/querying/metrics/fixing) by reducing the number of
time series those queries return.

## Alias expressions

[Derived metrics](/investigate/querying/metrics/derived-telemetry/derived-metrics) and
[derived labels](/investigate/querying/metrics/derived-telemetry/derived-labels) provide frequently
used aliases for queries without impacting persisted data limits.

Derived metrics help reduce alert and dashboard complexity, replace
[recording rules](/control/shaping/shape-metrics/rules/recording), and provide frequently used
aliases for queries.

Derived labels are non-destructive, and are specifically designed for efficient
operations on time series at scale. Unlike Prometheus relabel rules, which overwrite
existing data, derived labels standardize your label names without overwriting them
permanently.
