-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feature]: Support managing Monte Carlo monitors #52
Comments
Hello @mubarak-j 👋 Right now I am working on Monte Carlo's authorization groups. This effort will result into two new resources Once this implementation is finished I can start working on this issue. Originally I did not plan to implement monitors functionality in this provider, since alternative solution is using Monitors as Code architecture (e.g. deploying monitors from git repositories). However, if you find this functionality really useful I'll definitely look into its implementation (if its possible via API). In the meantime, could you please describe how the solution should work ?
resource "montecarlo_monitor" "example" {
monitor = file("${path.module}/mc_monitors/my_monitor.yml")
namespace = "namespace"
default_resource = "bigquery-warehouse-main"
}
resource "montecarlo_monitor_field_health" "example" {
table = "project:dataset.table_name"
timestamp_field = "created"
namespace = "namespace"
default_resource = "bigquery-warehouse-main"
}
resource "montecarlo_monitor_dimension_tracking" "example" {
table = "project:dataset.table_name"
timestamp_field = "created"
field = "order_status"
namespace = "namespace"
default_resource = "bigquery-warehouse-main"
} Thank you very much for opening this issue and contributing to this provider ! I really appreciate issues like this because it makes this provider more generally applicable. If you know about any other functionalities, that you would like this provider to implement, feel free to open another issue ! Thanks in advance for your response and your time ! |
Thank you for considering this feature. I think the first option will work for us and probably allow this provider more flexibility with MC API changes. I imagine we could use the yaml monitor file in an internal module and iterate over various fields/variables using TF |
@mubarak-j 👋 Hope you are doing well. I finally found some time for a simple refactoring in this repository (restructuring packages and reworking the acceptance tests to work against a real Monte Carlo instance), and I've started working on this issue. So far, I can verify that the requested functionality can indeed be achieved via this endpoint: However, it seems a lot of unusual approaches (for a terraform provider) will have to be used, e.g., implementing a I'll keep you updated here. |
So, I've tried implementing this through multiple approaches, but unfortunately, it seems that the option we agreed upon will not work with Terraform. However, I still believe that the monitors could be implemented using the second proposed solution. With the experience gained from previous attempts, I genuinely think the second option is ultimately simpler to implement.
Approach by loading monitor specification from .yml fileresource "montecarlo_monitor" "example" {
default_warehouse = "TestAccWarehouseDataSource"
configuration = file("./monitors/monitor.yaml")
} NamespaceEach Terraform resource can run in parallel with other resources and, for this reason, should be idempotent. Consequently, the resource example above needed to generate a unique namespace for each monitor
State issuesStoring monitor configuration inside a file used as input for the aforementioned resource results in non-standard Terraform output, as shown in the following example. This behavior could potentially impact general Terraform usage. # montecarlo_monitor.example will be updated in-place
~ resource "montecarlo_monitor" "example" {
~ configuration = <<-EOT
montecarlo:
- dimension_tracking:
- - aggregation_time_interval: hour
- description: Dimension Tracking for product_name in data-playground-8bb9fc23:terraform_provider_montecarlo.device
- field: product_name
- lookback_days: 1
- notify_rule_run_failure: true
- resource: TestAccWarehouseDataSource
- schedule:
- interval_minutes: 720
- start_time: "2023-12-04T12:53:06.823000+00:00"
- timezone: UTC
- type: fixed
- table: data-playground-8bb9fc23:terraform_provider_montecarlo.device
- use_partition_clause: false
+ dimension_tracking:
+ - resource: TestAccWarehouseDataSource
+ table: data-playground-8bb9fc23:terraform_provider_montecarlo.device
+ lookback_days: 1
+ aggregation_time_interval: hour
+ schedule:
+ type: fixed
+ interval_minutes: 720
+ start_time: '2023-12-04T12:53:06.823000+00:00'
+ timezone: UTC
+ description: Dimension Tracking for product_name in data-playground-8bb9fc23:terraform_provider_montecarlo.device
+ notify_rule_run_failure: true
+ field: product_name
+ use_partition_clause: false
EOT
# (2 unchanged attributes hidden)
} Passing monitor configurations through the
{
"mode": "managed",
"type": "montecarlo_monitor",
"name": "example",
"provider": "provider[\"registry.terraform.io/kiwicom/montecarlo\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"configuration": "---\nmontecarlo:\n json_schema:\n - resource: TestAccWarehouseDataSource\n table: data-playground-8bb9fc23:terraform_provider_montecarlo.device\n lookback_days: 1\n aggregation_time_interval: day\n schedule:\n type: fixed\n interval_minutes: 720\n start_time: '2023-12-04T12:01:18.703000+00:00'\n timezone: UTC\n description: JSON Schema monitor for quantity in device\n notify_rule_run_failure: true\n field: quantity\n dimension_tracking:\n - resource: TestAccWarehouseDataSource\n table: data-playground-8bb9fc23:terraform_provider_montecarlo.device\n lookback_days: 1\n aggregation_time_interval: hour\n schedule:\n type: fixed\n interval_minutes: 720\n start_time: '2023-12-04T12:53:06.823000+00:00'\n timezone: UTC\n description: Dimension Tracking for product_name in data-playground-8bb9fc23:terraform_provider_montecarlo.device\n notify_rule_run_failure: true\n field: product_name\n use_partition_clause: false\n - resource: TestAccWarehouseDataSource\n name: lol\n table: data-playground-8bb9fc23:terraform_provider_montecarlo.device\n lookback_days: 1\n aggregation_time_interval: hour\n schedule:\n type: fixed\n interval_minutes: 720\n start_time: '2023-12-04T12:53:06.823000+00:00'\n timezone: UTC\n description: Dimension Tracking for product_name in data-playground-8bb9fc23:terraform_provider_montecarlo.device\n notify_rule_run_failure: true\n field: product_name\n use_partition_clause: false",
"default_warehouse": "TestAccWarehouseDataSource",
"resources": {
"0fe1f21c-dff5-4b74-9256-e5a675569e79": "monitor|type=categories|table=data-playground-8bb9fc23:terraform_provider_montecarlo.device|timestamp_field=\u003c\u003cNULL\u003e\u003e|where_condition=\u003c\u003cNULL\u003e\u003e|field=product_name",
"b556afac-6762-4bb7-9375-013063f024a4": "monitor|type=json_schema|table=data-playground-8bb9fc23:terraform_provider_montecarlo.device|timestamp_field=\u003c\u003cNULL\u003e\u003e|where_condition=\u003c\u003cNULL\u003e\u003e|field=quantity",
"ba92463f-b8b3-4a2b-ae55-37a61e52b5d9": "lol"
},
"uuid": "deb666ec-c0ae-49ce-bcb8-f8ed65d27c09"
},
"sensitive_attributes": []
}
]
} ResolutionOverall, it appears that integrating Terraform with an additional Infrastructure as a Code tool like Monte Carlo MaaC does not yield smooth integration. While the aforementioned approach could be implemented with sufficient motivation, it would significantly increase the complexity of this provider and introduce behavior that is not standard for Terraform providers." @mubarak-j 👋 I will proceed with the implementation using the specific monitor resources (option 2 that we discussed), likely beginning with the Custom SQL Rule monitor. For more effective management, new issues should be created for each monitor 'type.' Therefore, if there is any monitor type you would like to see supported promptly, please feel free to open a new feature request for that specific monitor type and link to this issue within it. |
Contact Details
[email protected]
Feature Request Details
Thank you for all the great work on this valuable provider in such a short time, much appreciated! 🙌🏼
If this is something aligned with the provider roadmap, I'd like to request adding the support for creating, managing, and importing Monte Carlo monitors.
I understand that MC monitors vary in type and API fields and this might be a complex effort, please feel free to break up this effort into multiple issues and/or TF resources. Thank you!
Acceptance Criteria
Importance of the feature
must have
Checklist
The text was updated successfully, but these errors were encountered: