Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add related files to set Freshness and Volume on all glean tables #6296

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bigquery_etl/cli/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def update(name: str, sql_dir: Optional[str], project_id: Optional[str]) -> None
),
metric_schedule=SimpleMetricSchedule(
named_schedule=SimpleNamedSchedule(
name="Default Schedule - 17:00 UTC"
name="Default Schedule - 13:00 UTC"
)
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ table_deployments:
predefined_metric: FRESHNESS
metric_schedule:
named_schedule:
name: Default Schedule - 17:00 UTC
name: Default Schedule - 13:00 UTC
- metric_type:
type: PREDEFINED
predefined_metric: VOLUME
metric_schedule:
named_schedule:
name: Default Schedule - 17:00 UTC
name: Default Schedule - 13:00 UTC
16 changes: 16 additions & 0 deletions sql_generators/glean_usage/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def generate_per_app_id(
view_metadata_filename = f"{self.target_table_id[:-3]}.metadata.yaml"
table_metadata_filename = f"{self.target_table_id}.metadata.yaml"
schema_filename = f"{self.target_table_id}.schema.yaml"
bigconfig_filename = f"{self.target_table_id}.bigconfig.yml"

table = tables[f"{self.prefix}_table"]
view = tables[f"{self.prefix}_view"]
Expand All @@ -248,6 +249,7 @@ def generate_per_app_id(
app_name=app_name,
has_distribution_id=app_name in APPS_WITH_DISTRIBUTION_ID,
has_profile_group_id= app_name in APPS_WITH_PROFILE_GROUP_ID,
target_table=f"{self.target_table_id}",
)

render_kwargs.update(self.custom_render_kwargs)
Expand Down Expand Up @@ -291,6 +293,17 @@ def generate_per_app_id(
)
except TemplateNotFound:
schema = None

# Bigconfig files are optional
try:
bigconfig = render(
bigconfig_filename,
format=False,
template_folder=PATH / "templates",
**render_kwargs,
)
except TemplateNotFound:
bigconfig = None

# generated files to update
Artifact = namedtuple("Artifact", "table_id basename sql")
Expand Down Expand Up @@ -319,6 +332,9 @@ def generate_per_app_id(

if schema:
artifacts.append(Artifact(table, "schema.yaml", schema))

if bigconfig:
artifacts.append(Artifact(table, "bigconfig.yml", bigconfig))

for artifact in artifacts:
destination = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: BIGCONFIG_FILE
table_deployments:
- collection:
name: Test
deployments:
- fq_table_name: {{ project_id }}.{{ project_id }}.{{ derived_dataset }}.{{ target_table }}
table_metrics:
- metric_type:
type: PREDEFINED
predefined_metric: FRESHNESS
metric_schedule:
named_schedule:
name: Default Schedule - 13:00 UTC
- metric_type:
type: PREDEFINED
predefined_metric: VOLUME
metric_schedule:
named_schedule:
name: Default Schedule - 13:00 UTC

Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ bigquery:
schema:
derived_from:
- table: ['moz-fx-data-shared-prod', '{{ derived_dataset }}', 'baseline_clients_daily_v1']
monitoring:
enabled: true