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

[ISSUE] Issue with databricks_alert resource #4483

Open
mathiaspetersepi opened this issue Feb 11, 2025 · 5 comments
Open

[ISSUE] Issue with databricks_alert resource #4483

mathiaspetersepi opened this issue Feb 11, 2025 · 5 comments
Labels
plugin framework This issue will be resolved when we migrate towards using the plugin framework.

Comments

@mathiaspetersepi
Copy link

The example code of the databricks_alert resource creates a broken alert. The condition is not evaluated correctly.
I am using aquery which returns a single integer column "number_of_events". I want to trigger the alert if the attribute value of the first row is 0.
The documentation does not show any options to configure the first row into the trigger condition.

Configuration

resource "databricks_alert" "raw_wallets_empty_alert" {
  query_id     = databricks_query.monitoring_query_wallets.id
  display_name = "Raw Wallets stale for 12 hrs"
  parent_path  = databricks_directory.shared_dir.path

  condition {
    op = "EQUAL"
    operand {
      column {
        name = "number_of_events"
      }
    }
    threshold {
      value {
        double_value = 0
      }
    }
    empty_result_state = "OK"
  }
}

Expected Behavior

The evaluation criterion should be displayed correctly.

Actual Behavior

The trigger condition is broken.
Image

@alexott
Copy link
Contributor

alexott commented Feb 11, 2025

it looks like it a problem with API - I don't see any option for specifying first row and other params: https://docs.databricks.com/api/workspace/alerts/create

@alexott
Copy link
Contributor

alexott commented Feb 11, 2025

I chatted with the dev team - the "First Row" is the default operation. The gap in that API is known, but there is no ETA for adding it.

@alexott alexott added the needs-api changes to Databricks Platform APIs are required label Feb 11, 2025
@mathiaspetersepi
Copy link
Author

Since I followed the terraform example: does that mean the resource is broken or did I use it incorrectly?

@alexott alexott added plugin framework This issue will be resolved when we migrate towards using the plugin framework. and removed needs-api changes to Databricks Platform APIs are required labels Feb 12, 2025
@alexott
Copy link
Contributor

alexott commented Feb 12, 2025

Ok, I dug deeper into it - the problem is caused by having omitempty on the attribute definition. This causes the 0 value not to be sent as a payload because TF SDK doesn't distinguish between the 0 value that is specified and if it's not specified at all:

<   "condition": {
<     "empty_result_state": "OK",
<     "op": "EQUAL",
<     "operand": {
<       "column": {
<         "name": "count"
<       }
<     },
<     "threshold": {
<       "value": {}
<     }
<   },

Unfortunately, this could be solved only by porting this resource to the TF plugin framework that allows to distinguish between the 0 value that is set and not specified value.

The current workaround would be to use string_value = "0" instead (similarly for string_value = "false" for bool_value = false).

@mathiaspetersepi
Copy link
Author

Can confirm, that this workaround does the trick. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin framework This issue will be resolved when we migrate towards using the plugin framework.
Projects
None yet
Development

No branches or pull requests

2 participants