Filter ingested data

Last updated:

|Edit this page

This transformation enables you to create filters which prevent PostHog from ingesting data from your product unless it passes those filters. Any events which do not match the filter requirements are skipped over and are not ingested.

Requirements

Using this requires either PostHog Cloud with the data pipelines add-on, or a self-hosted PostHog instance running a recent version of the Docker image.

Installation

  1. In PostHog, click the "Data pipeline" tab in the left sidebar.
  2. Search for 'Filter Out' and select the transformation, press Install.
  3. Follow the on-screen steps to configure the transformation.

This transformation will only work on events ingested after the transformation was enabled.

Configuration

The transformation can be configured via a JSON file which specifies the properties you would like to filter.

In the example config below, the transformation will only keep events where all of the following conditions are met:

  • Email does not contain yourcompany.com
  • Host is not localhost:8000
  • Browser version greater than 100
[
{
"property": "email",
"type": "string",
"operator": "not_contains",
"value": "yourcompany.com"
},
{
"property": "$host",
"type": "string",
"operator": "is_not",
"value": "localhost:8000"
},
{
"property": "$browser_version",
"type": "number",
"operator": "gt",
"value": 100
}
]

The followed types and operators are allowed:

TypeOperators
numbergt, gte, lt, lte, eq, neq
stringis, is_not, contains, not_contains, regex, not_regex
booleanis, is_not

FAQ

How can I filter out events from unwanted hostnames or IP addresses?

To filter out all traffic from hosts that are not (for example) posthog.com, you could use the following config:

[
{
"property": "$host",
"type": "string",
"operator": "is",
"value": "posthog.com"
}
]

Or, to filter out all traffic from a particular IP address, you could use a config like this example:

[
{
"property": "$ip",
"type": "string",
"operator": "is_not",
"value": "192.168.01.123"
}
]

Make sure to enable the Keep event if any of the filtered properties are undefined? option, otherwise, any events where the $host property is undefined will be filtered out.

Do you pay for events filtered out?

No. Since PostHog doesn't ingest the events you filter out, you don't pay for them.

Who maintains this?

This is maintained by the community. If you have issues with it not functioning as intended, please let us know!

What if I have feedback on this destination?

We love feature requests and feedback. Please tell us what you think.

What if my question isn't answered above?

We love answering questions. Ask us anything via our community forum.

Questions? Ask Max AI.

It's easier than reading through 608 docs articles.

Community questions

Was this page useful?

Next article

Enrich PostHog analytics with IP location data

This transformation enriches PostHog events and persons with IP location data. Simply enable this transformation and from that point on, your new events will have GeoIP data added, allowing you to locate users and run queries based on geographic data. How it works This transformation prefers to use event property $ip (which should be of type string ), but if that is not provided, it uses the IP address of the client that sent the event. This way the transformation can, in most cases, infer…

Read next article