Skip to main content

Samarth Analytics

Analytics Data Quality & Observability Best Practices

Great Expectations, dbt tests, Monte Carlo patterns - how to know your dashboards are wrong before your CEO does.

By Samarth Analytics · Published · Updated · Analytics Engineering · 10 min read

Summary: A practical guide to data quality and observability for analytics. Covers the five pillars (freshness, volume, schema, distribution, lineage), dbt tests for transformation correctness, Great Expectations for validation, observability platforms (Monte Carlo, Bigeye), and incident response for data outages.

  • Data observability is essential for maintaining data quality.
  • Implement dbt tests to establish a strong foundation.
  • Utilize Great Expectations for comprehensive validation.
  • Consider managed observability tools, but beware of unnecessary costs.
  • Monitor data freshness and detect schema drift proactively.

The five pillars of data observability

Data observability encompasses several key areas that collectively contribute to data quality. Understanding these pillars can help you create a robust data observability framework:

  1. Data Freshness: Ensuring your data is up-to-date is critical. You want to monitor how current your data is, especially for reports and alerting tables.

  2. Data Volume: This involves keeping track of the amount of data flowing through your pipelines. Sudden drops or spikes can indicate issues that need immediate attention.

  3. Data Distribution: Understanding how data is distributed can help flag anomalies. For example, if a particular field's distribution suddenly changes, it may indicate a problem upstream.

  4. Schema Changes: Monitoring for changes in schema is vital. Changes can lead to broken reports or unexpected behavior if not detected early.

  5. Data Quality: This includes ensuring that the data meets certain standards, such as accuracy and reliability. Regular validation is needed to ensure adherence to these standards.

dbt tests: the baseline you should already have

We always recommend starting with dbt tests as they form the backbone of any data quality strategy. Here's why:

  • Not Null Tests: Ensures that critical fields do not contain null values, which can lead to misleading insights.
  • Unique Tests: Validates that fields expected to be unique, such as user IDs, are indeed unique, preventing duplication issues.
  • Relationships: Checks for referential integrity between tables, ensuring that all foreign keys point to valid records in their respective tables.
  • Accepted Values: Validates that a field’s values fall within a predefined set of acceptable values, which is crucial for categorical data.

Here's a sample schema.yml for a marketing_events model demonstrating these tests:

version: 2

models:
  - name: marketing_events
    description: "Table containing marketing event data"
    columns:
      - name: event_id
        description: "Unique identifier for each event"
        tests:
          - not_null
          - unique
      - name: user_id
        description: "Identifier for the user associated with the event"
        tests:
          - not_null
          - relationships:
              to: ref('users')
              field: id
      - name: event_type
        description: "Type of marketing event"
        tests:
          - accepted_values:
              values: ['email', 'social', 'organic', 'paid']

Great Expectations for deeper validation

While dbt tests are foundational, Great Expectations can provide an additional layer of validation. This tool helps enforce data quality with more complex assertions and expectations.

  • Expectation Suites: You can create different suites of expectations depending on the data's context. For example, a suite for marketing_events might include checks for user engagement metrics.
  • Data Documentation: With Great Expectations, you can automatically generate documentation that explains your expectations, making it easier for stakeholders to understand the data's quality.

Integrating Great Expectations into your workflow allows for more nuanced data validation, which is particularly useful as your data needs grow.

Managed observability (Monte Carlo, Bigeye, Soda)

Managed observability tools like Monte Carlo, Bigeye, and Soda can streamline your data quality efforts. However, we advise caution:

  • Ease of Use: These tools simplify data monitoring and alerting, allowing you to visualize data quality metrics without extensive coding.
  • Integration: They often come with integrations for popular data stacks which can save time in setup.

Warning: Many observability tools detect nothing you cannot already detect with dbt tests and a scheduled row-count check. The premium features are rarely worth the premium pricing for mid-market companies.

Consider your specific needs and ask whether the added complexity is justified by the insights these tools provide.

Detecting schema drift before it breaks reports

Schema drift can lead to broken reports and incorrect analyses. Here’s how to keep track of schema changes effectively:

  • Automated Monitoring: Implement automated checks that notify you when schema changes occur. This can include changes in column types, names, or new fields being added.
  • Version Control for Schemas: Use version control for your dbt models to track changes over time. This can help you quickly roll back if a schema change causes issues.
  • Documentation: Keep comprehensive documentation of your data model, including any changes, to help your team quickly understand the impact of schema changes.

Proactive monitoring for schema drift can save significant time and resources by preventing issues before they escalate.

Incident response: when a pipeline dies at 2am

Data pipelines can fail at any time, often when least expected. Having a solid incident response plan is crucial:

  1. Alerting Mechanisms: Set up alerts for failures, including automated messages to your team via your preferred communication channels (e.g., Slack, email).

  2. Runbooks: Maintain detailed runbooks that outline the steps to troubleshoot common issues. This resource should be easily accessible to your team.

  3. Postmortem Analysis: After resolving an incident, conduct a postmortem to understand what went wrong and how to prevent similar issues in the future.

  4. Testing and Simulations: Regularly test your incident response plan by simulating failures. This will prepare your team to respond effectively when real issues arise.

Lineage and impact analysis

Understanding data lineage and conducting impact analysis are crucial for effective data governance:

  • Data Lineage Tools: Implement tools that visualize data lineage to see how data flows through your systems. This aids in understanding the dependencies between data sources, transformations, and outputs.

  • Impact Analysis: Before making changes to data models or pipelines, evaluate the potential impact on downstream systems. This can prevent unintended consequences.

Common mistakes we see

  • Failing to implement basic dbt tests, leading to undetected data quality issues.
  • Over-reliance on managed observability tools without a solid foundation of internal checks.
  • Ignoring schema changes until they break reports, causing delays in response.
  • Not having a well-defined incident response plan, resulting in chaotic troubleshooting.
  • Lack of documentation for data models and schemas, making it difficult for teams to collaborate effectively.

Implementation checklist

  • Establish dbt tests for all critical models.
  • Implement Great Expectations for deeper validation.
  • Set up automated monitoring for schema changes.
  • Create alerting mechanisms for pipeline failures.
  • Document data lineage and impact analysis processes.
  • Conduct regular incident response simulations.
  • Review and refine data freshness SLAs regularly.

How Samarth Analytics helps

At Samarth Analytics, we specialize in optimizing data quality and observability. Our team can conduct a free audit of your current setup and help you implement best practices tailored to your needs. If you're ready to enhance your data infrastructure, contact us for a consultation.

All analytics guides · Markdown version of this guide