-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo_job.tf
61 lines (49 loc) · 1.47 KB
/
demo_job.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
resource "databricks_notebook" "calculate_pi" {
path = "${data.databricks_current_user.me.home}/dbx-obs-demo/CalculatePi"
language = "SCALA"
content_base64 = base64encode(<<-EOT
import scala.math.random
val n = 2000000000
val count = sc.parallelize(1 to n).map { i =>
val x = random * 2 - 1
val y = random * 2 - 1
if (x*x + y*y < 1) 1 else 0
}.reduce(_ + _)
println("Pi is roughly " + 4.0 * count / n)
EOT
)
}
resource "databricks_job" "demo-job" {
name = "DBX Observability Demo Job"
task {
task_key = "calculate-pi"
new_cluster {
num_workers = 4
spark_version = data.databricks_spark_version.latest_lts.id
node_type_id = data.databricks_node_type.smallest.id
init_scripts {
workspace {
destination = databricks_workspace_file.pyroscope_init.path
}
}
init_scripts {
workspace {
destination = databricks_workspace_file.prometheus_init.path
}
}
spark_conf = {
// pyroscope configuration
"spark.pyroscope.server" : "http://${var.pyroscope_host}",
"spark.pyroscope.applicationName" : "dbx-obs-demo",
"spark.plugins" : "ch.cern.PyroscopePlugin"
}
spark_env_vars = {
"PROMETHEUS_HOST" : var.prometheus_pushgateway_host
"PROMETHEUS_JOB_NAME" : "dbx-calculate-pi"
}
}
notebook_task {
notebook_path = databricks_notebook.calculate_pi.path
}
}
}