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

feat: Write Metrics to BigQuery #1696

Merged
merged 96 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
935e8db
refactor for testing
tristanvuong2021 Jul 26, 2024
c4e942a
add comments and unit tests
tristanvuong2021 Jul 31, 2024
15820b2
lint fix
tristanvuong2021 Jul 31, 2024
d71ae81
fix fields
tristanvuong2021 Jul 31, 2024
077a92e
lint fix
tristanvuong2021 Jul 31, 2024
68ecbe0
Switch to internal service from spanner
tristanvuong2021 Jul 31, 2024
01ac939
lint fix
tristanvuong2021 Jul 31, 2024
bf873ad
Add measurements unit test
tristanvuong2021 Aug 1, 2024
d7998a3
lint fix
tristanvuong2021 Aug 1, 2024
cfbca13
deploy
tristanvuong2021 Aug 1, 2024
1746600
deploy
tristanvuong2021 Aug 1, 2024
1951e05
deploy
tristanvuong2021 Aug 1, 2024
9c00308
push
tristanvuong2021 Aug 1, 2024
3cd5575
deploy
tristanvuong2021 Aug 1, 2024
f19798f
major refactor
tristanvuong2021 Aug 1, 2024
20f2836
lint fix
tristanvuong2021 Aug 1, 2024
c5b1124
lint fix
tristanvuong2021 Aug 1, 2024
513eb99
lint fix
tristanvuong2021 Aug 1, 2024
86cea12
deploy
tristanvuong2021 Aug 1, 2024
efa3d50
deploy
tristanvuong2021 Aug 1, 2024
373b6b8
deploy
tristanvuong2021 Aug 1, 2024
a33e316
deploy
tristanvuong2021 Aug 1, 2024
83838f6
lint fix
tristanvuong2021 Aug 1, 2024
2da8d58
refactor
tristanvuong2021 Aug 2, 2024
de1625b
lint fix
tristanvuong2021 Aug 2, 2024
a52f81e
refactor
tristanvuong2021 Aug 9, 2024
670a730
lint fix
tristanvuong2021 Aug 9, 2024
ef6949a
mock bigquerywriteclient for github tests
tristanvuong2021 Aug 9, 2024
a433d07
lint fix
tristanvuong2021 Aug 9, 2024
e459f56
refactor
tristanvuong2021 Aug 13, 2024
ead96eb
lint fix
tristanvuong2021 Aug 13, 2024
bae7d11
Change computation key to include measurement id
tristanvuong2021 Aug 13, 2024
900f9bb
lint fix
tristanvuong2021 Aug 13, 2024
bf30dbe
refactor
tristanvuong2021 Aug 15, 2024
4ef1ea1
merge
tristanvuong2021 Aug 15, 2024
ab5bfad
push new image
tristanvuong2021 Aug 15, 2024
f54c0a6
deploy
tristanvuong2021 Aug 15, 2024
dc3e93a
push
tristanvuong2021 Aug 15, 2024
144e40d
deploy
tristanvuong2021 Aug 15, 2024
79c641c
fix missing types
tristanvuong2021 Aug 15, 2024
eadc6c2
deploy
tristanvuong2021 Aug 15, 2024
7fccbeb
push
tristanvuong2021 Aug 15, 2024
86e088b
deploy
tristanvuong2021 Aug 15, 2024
b8d037d
push new query change
tristanvuong2021 Aug 15, 2024
ffe5449
deploy
tristanvuong2021 Aug 15, 2024
695cf30
deploy
tristanvuong2021 Aug 15, 2024
ba2b131
push
tristanvuong2021 Aug 15, 2024
f08a3c3
deploy
tristanvuong2021 Aug 15, 2024
8c2c5fc
deploy
tristanvuong2021 Aug 15, 2024
dea41ae
deploy
tristanvuong2021 Aug 15, 2024
72914b6
push
tristanvuong2021 Aug 15, 2024
9095fa1
push
tristanvuong2021 Aug 15, 2024
433a813
deploy
tristanvuong2021 Aug 15, 2024
66d8e8a
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Aug 15, 2024
4d02469
deploy
tristanvuong2021 Aug 16, 2024
1b10610
deploy
tristanvuong2021 Aug 16, 2024
5c667f1
deploy
tristanvuong2021 Aug 16, 2024
010e7af
deploy
tristanvuong2021 Aug 16, 2024
74e58fb
deploy
tristanvuong2021 Aug 16, 2024
0e2f67d
deploy
tristanvuong2021 Aug 16, 2024
a2e3fb0
change schedule time
tristanvuong2021 Aug 16, 2024
30e3ee0
Merge remote-tracking branch 'origin/main' into tristanvuong-write-me…
tristanvuong2021 Aug 16, 2024
9f28ded
push
tristanvuong2021 Aug 16, 2024
80405da
test bigger batch size
tristanvuong2021 Aug 16, 2024
5917f75
reduce batch size
tristanvuong2021 Aug 16, 2024
aaefc67
deploy
tristanvuong2021 Aug 16, 2024
71b98a1
push
tristanvuong2021 Aug 16, 2024
bec5327
deploy
tristanvuong2021 Aug 16, 2024
b40067f
change schedule time
tristanvuong2021 Aug 16, 2024
23675f7
turn off deploy
tristanvuong2021 Aug 16, 2024
53f1e26
Increase container memory and add comment
tristanvuong2021 Aug 16, 2024
9490842
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Aug 19, 2024
7a8a725
remove workflow changes
tristanvuong2021 Aug 19, 2024
d0c43bd
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Aug 20, 2024
0ce1a40
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Aug 21, 2024
298d837
Merge remote-tracking branch 'origin/main' into tristanvuong-write-me…
tristanvuong2021 Aug 21, 2024
e4cc6e8
Remove archive override
tristanvuong2021 Aug 21, 2024
bca9788
test
tristanvuong2021 Aug 22, 2024
c057447
undo test
tristanvuong2021 Aug 22, 2024
3aab7b9
try upgrading kubernetes client
tristanvuong2021 Aug 22, 2024
2e3af10
test
tristanvuong2021 Aug 22, 2024
c2752a0
Merge remote-tracking branch 'origin/main' into tristanvuong-write-me…
tristanvuong2021 Aug 22, 2024
b0bc3a4
merge
tristanvuong2021 Aug 22, 2024
5bfd19e
test
tristanvuong2021 Aug 22, 2024
a4536ff
test
tristanvuong2021 Aug 22, 2024
ec2c3c2
remove computation participants table from bigquery metrics
tristanvuong2021 Aug 23, 2024
024b88b
lint fix
tristanvuong2021 Aug 23, 2024
4e8c865
Merge remote-tracking branch 'origin/main' into tristanvuong-write-me…
tristanvuong2021 Sep 9, 2024
e7960a3
merge fix
tristanvuong2021 Sep 9, 2024
c0c38dd
Merge remote-tracking branch 'origin/main' into tristanvuong-write-me…
tristanvuong2021 Sep 10, 2024
9ee52ae
fix merge
tristanvuong2021 Sep 10, 2024
832dddf
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Sep 11, 2024
75f2a23
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Sep 12, 2024
972324d
fix merge
tristanvuong2021 Sep 12, 2024
df68422
lint fix
tristanvuong2021 Sep 12, 2024
b712890
Merge branch 'main' into tristanvuong-write-metrics-bq
tristanvuong2021 Sep 13, 2024
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
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ maven.install(
"org.slf4j:slf4j-simple:1.7.32",

# Google Cloud
"com.google.cloud:google-cloud-bigquerystorage",
"com.google.cloud:google-cloud-security-private-ca",
# TODO(googleapis/java-cloud-bom#5279): Remove when managed by BOM.
"com.google.apis:google-api-services-storage:v1-rev20240706-2.0.0",
Expand Down
6 changes: 6 additions & 0 deletions imports/java/com/google/cloud/bigquery/storage/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])

alias(
name = "storage",
actual = "@maven//:com_google_cloud_google_cloud_bigquerystorage",
)
72 changes: 70 additions & 2 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 1120915116,
"__RESOLVED_ARTIFACTS_HASH": -2081716671,
"__INPUT_ARTIFACTS_HASH": 606715834,
"__RESOLVED_ARTIFACTS_HASH": -1010776065,
"artifacts": {
"args4j:args4j": {
"shasums": {
Expand Down Expand Up @@ -3426,6 +3426,44 @@
"com.google.http-client:google-http-client",
"com.google.http-client:google-http-client-gson"
],
"com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1": [
"com.google.api.grpc:proto-google-common-protos",
"com.google.api:api-common",
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"io.grpc:grpc-protobuf-lite",
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta1": [
"com.google.api.grpc:proto-google-common-protos",
"com.google.api:api-common",
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"io.grpc:grpc-protobuf-lite",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta2": [
"com.google.api.grpc:proto-google-common-protos",
"com.google.api:api-common",
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"io.grpc:grpc-protobuf-lite",
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:grpc-google-cloud-bigtable-admin-v2": [
"com.google.api.grpc:proto-google-cloud-bigtable-admin-v2",
"com.google.api.grpc:proto-google-common-protos",
Expand Down Expand Up @@ -3548,6 +3586,36 @@
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:proto-google-cloud-bigquerystorage-v1alpha": [
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta1": [
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta2": [
"com.google.auto.value:auto-value-annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:failureaccess",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"javax.annotation:javax.annotation-api",
"org.checkerframework:checker-qual"
],
"com.google.api.grpc:proto-google-cloud-bigtable-admin-v2": [
"com.google.api.grpc:proto-google-common-protos",
"com.google.api.grpc:proto-google-iam-v1",
Expand Down
5 changes: 5 additions & 0 deletions src/main/docker/images.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ GKE_IMAGES = [
image = "//src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/postgres/tools:update_schema_image",
repository = _PREFIX + "/duchy/gcloud-postgres-update-schema",
),
struct(
name = "kingdom_operational_metrics_export_image",
image = "//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/job:operational_metrics_export_job_image",
repository = _PREFIX + "/kingdom/bigquery-operational-metrics",
),
]

# List of specs for all Docker containers to push to a container registry.
Expand Down
72 changes: 72 additions & 0 deletions src/main/k8s/dev/kingdom_gke.cue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ _systemApiAddressName: string @tag("system_api_address_name")
// Name of K8s service account for the internal API server.
#InternalServerServiceAccount: "internal-server"

// Name of K8s service account for the operational metrics job.
#OperationalMetricsServiceAccount: "operational-metrics"

// Number of gRPC threads for the internal API server.
#InternalServerGrpcThreads: 7

Expand All @@ -40,6 +43,16 @@ _systemApiAddressName: string @tag("system_api_address_name")
}
}

#OperationalMetricsJobResourceRequirements: ResourceRequirements=#ResourceRequirements & {
requests: {
cpu: "10m"
memory: "256Mi"
}
limits: {
memory: ResourceRequirements.requests.memory
}
}

objectSets: [defaultNetworkPolicies] + [ for objectSet in kingdom {objectSet}]

kingdom: #Kingdom & {
Expand All @@ -48,10 +61,30 @@ kingdom: #Kingdom & {

_verboseGrpcServerLogging: true

_imageSuffixes: [string]: string
_imageSuffixes: {
"operational-metrics": string | *"kingdom/bigquery-operational-metrics"
}
_imageConfigs: [string]: #ImageConfig
_imageConfigs: {
for name, suffix in _imageSuffixes {
"\(name)": {repoSuffix: suffix}
}
}
_images: [string]: string
_images: {
for name, config in _imageConfigs {
"\(name)": config.image
}
}

serviceAccounts: {
"\(#InternalServerServiceAccount)": #WorkloadIdentityServiceAccount & {
_iamServiceAccountName: "kingdom-internal"
}
"\(#OperationalMetricsServiceAccount)": #WorkloadIdentityServiceAccount & {
_iamServiceAccountName: "operational-metrics"
}
}

configMaps: "java": #JavaConfigMap
Expand All @@ -73,6 +106,45 @@ kingdom: #Kingdom & {
}
}

cronJobs: {
"operational-metrics": {
_container: {
_javaOptions: maxHeapSize: "48M"
image: _images["operational-metrics"]
resources: #OperationalMetricsJobResourceRequirements
args: [
"--bigquery-project=\(#GCloudProject)",
"--bigquery-dataset=operational_metrics",
"--measurements-table=measurements",
"--requisitions-table=requisitions",
"--latest-measurement-read-table=latest_measurement_read",
"--tls-cert-file=/var/run/secrets/files/kingdom_tls.pem",
"--tls-key-file=/var/run/secrets/files/kingdom_tls.key",
"--cert-collection-file=/var/run/secrets/files/kingdom_root.pem",
"--internal-api-target=" + (#Target & {name: "gcp-kingdom-data-server"}).target,
"--internal-api-cert-host=localhost",
]
}
spec: {
concurrencyPolicy: "Forbid"
schedule: "30 * * * *" // Hourly, 30 minutes past the hour
jobTemplate: spec: template: spec: #ServiceAccountPodSpec & {
serviceAccountName: #OperationalMetricsServiceAccount
}
}
}
}

networkPolicies: {
"operational-metrics": {
_app_label: "operational-metrics-app"
_egresses: {
// Need to send external traffic to BigQuery.
any: {}
}
}
}

services: {
"system-api-server": _ipAddressName: _systemApiAddressName
"v2alpha-public-api-server": _ipAddressName: _publicApiAddressName
Expand Down
1 change: 1 addition & 0 deletions src/main/k8s/kingdom.cue
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ import ("strings")
"completed-measurements-deletion-app",
"pending-measurements-cancellation-app",
"exchanges-deletion-app",
"operational-metrics-app",
]
_egresses: {
// Need to send external traffic to Spanner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ kt_jvm_library(
kt_jvm_library(
name = "utils",
srcs = ["Utils.kt"],
visibility = ["//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/job:__subpackages__"],
visibility = [
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/job:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/job:__subpackages__",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/common/identity",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common:flags",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
load("@rules_java//java:defs.bzl", "java_binary")
load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_library")
load("//src/main/docker:macros.bzl", "java_image")

kt_jvm_library(
name = "operational_metrics_export_job",
srcs = ["OperationalMetricsExportJob.kt"],
runtime_deps = ["@wfa_common_jvm//imports/java/io/grpc/netty"],
deps = [
":operational_metrics_export",
"//imports/java/com/google/cloud/bigquery/storage",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/server:utils",
"//src/main/proto/wfa/measurement/internal/kingdom:measurements_service_kt_jvm_grpc_proto",
"@wfa_common_jvm//imports/java/com/google/cloud/bigquery",
"@wfa_common_jvm//imports/java/picocli",
"@wfa_common_jvm//imports/kotlin/kotlinx/coroutines:core",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/crypto:signing_certs",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/grpc",
],
)

java_binary(
name = "OperationalMetricsExportJob",
main_class = "org.wfanet.measurement.kingdom.deploy.gcloud.job.OperationalMetricsExportJobKt",
runtime_deps = [":operational_metrics_export_job"],
)

java_image(
name = "operational_metrics_export_job_image",
binary = ":OperationalMetricsExportJob",
main_class = "org.wfanet.measurement.kingdom.deploy.gcloud.job.OperationalMetricsExportJobKt",
visibility = ["//src:docker_image_deployment"],
)

kt_jvm_library(
name = "operational_metrics_export",
srcs = ["OperationalMetricsExport.kt"],
visibility = ["//src/test/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/job:__pkg__"],
deps = [
":stream_writer_factory",
"//imports/java/com/google/cloud/bigquery/storage",
"//src/main/kotlin/org/wfanet/measurement/api:public_api_version",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:packed_messages",
"//src/main/proto/wfa/measurement/api/v2alpha:measurement_spec_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:measurements_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/kingdom/bigquerytables:operational_metrics_dataset_kt_jvm_proto",
"@wfa_common_jvm//imports/java/com/google/cloud/bigquery",
"@wfa_common_jvm//imports/kotlin/kotlinx/coroutines:core",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/identity",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/gcloud/common",
],
)

kt_jvm_library(
name = "stream_writer_factory",
srcs = ["StreamWriterFactory.kt"],
visibility = ["//src/test/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/job:__pkg__"],
deps = [
"//imports/java/com/google/cloud/bigquery/storage",
],
)
Loading
Loading