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

azurerm_log_analytics_data_export_rule - support for the destination_metadata property #17019

Closed
wants to merge 15 commits into from

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented May 31, 2022

This PR is to support new property destination_metadata.

Note: I think service team would expand the sub properties of destination_metadata in the future so that I make it as block.

--- PASS: TestAccLogAnalyticsDataExportRule_basic (295.37s)
--- PASS: TestAccLogAnalyticsDataExportRule_complete (303.93s)
--- PASS: TestAccLogAnalyticsDataExportRule_requiresImport (334.64s)
--- PASS: TestAccLogAnalyticsDataExportRule_destinationMetadata (405.26s)
--- PASS: TestAccLogAnalyticsDataExportRule_update (435.80s)

@magodo
Copy link
Collaborator

magodo commented Jun 7, 2022

@neil-yechenwei LGTM 👍

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neil-yechenwei LGTM as well, just one minor comment about the documentation. 🚀

@neil-yechenwei neil-yechenwei requested a review from WodansSon June 7, 2022 03:38
Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neil-yechenwei Thanks for pushing that change, LGTM! 🚀


The `metadata` block supports the following attributes:

* `eventhub_name` - (Optional) The name of the EventHub that is defined for the Log Analytics Data Export Rule.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, what is this actually doing? if this is setting anything? just a place to put the destination event hub name? should it just be

Suggested change
* `eventhub_name` - (Optional) The name of the EventHub that is defined for the Log Analytics Data Export Rule.
* `destination_eventhub_name` - (Optional) The name of the EventHub that Log Analytics Data Export Rule exports too.

also given we are giving the id above? what is the point of this? could we not just grab it from the ID and set it ourselves so the user doesn't have to?

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means "Select an Event Hub name to send data from all tables in the rule to a specific Event Hub. If nothing is selected, an Event Hub is created for each table in the selected namespace".

When this is setting anything, it would fail.

I think it's better to update metadata to destination_metadata and keep eventhub_name since maybe service team would introduce other destinations.

As this azure doc indicates "Select an Event Hub name to send data from all tables in the rule to a specific Event Hub. If nothing is selected, an Event Hub is created for each table in the selected namespace.", so I think supporting this property is meaningful.

As setting it or not setting it represents different meaning, so I think it should be set by user. And destination_resource_id should be set with eventhub namespace resource id or storage account id not eventhub resource id. Below data export rule is created on Azure Portal and the destination resource id is set with eventhub namespace resource id.
image
image

Copy link
Collaborator

@katbyte katbyte Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well i think that's pretty self explanatory, we should match what the portal is doing. and really. going by these images, maybe have two resources 1 for storage account, 1 for eventhubs - there no metadata in those pages, and the property names are much easier to decipher when correctly named vs being overloaded in the api

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure portal also allows to set or not set event hub name under destination metadata. So I assume my PR is aligned with Azure Portal. If I am wrong, please correct me.

Currently the destination metadata only supports event hub name.

I already updated the property name and the name description. Seems you're still referencing old commit. Could you refresh your PR to get my latest update?Thanks.

And suggest go thourgh this azure doc (https://docs.microsoft.com/en-us/azure/azure-monitor/logs/logs-data-export?tabs=portal#create-or-update-data-export-rule) and play this log analytics data export rule resource on Azure Portal first.

Or could you provide the suggested code/commit for them? Thanks in advance.

image
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i'm thinking is we model the two twps you can select in the portal:

resource "azurerm_log_analytics_data_export_rule_storage_account" "test" {
  name                    = "acctest-DER-%d"
  resource_group_name     = azurerm_resource_group.test.name
  workspace_resource_id   = azurerm_log_analytics_workspace.test.id
  table_names             = ["Heartbeat"]

  destination_storage_account_id = 
}

resource "azurerm_log_analytics_data_export_rule_evenhub" "test" {
  name                    = "acctest-DER-%d"
  resource_group_name     = azurerm_resource_group.test.name
  workspace_resource_id   = azurerm_log_analytics_workspace.test.id
  table_names             = ["Heartbeat"]

  destination_evenhub_id = azurerm_eventhub.test.id
}

or even

resource "azurerm_log_analytics_data_export_rule" "test" {
  name                    = "acctest-DER-%d"
  resource_group_name     = azurerm_resource_group.test.name
  workspace_resource_id   = azurerm_log_analytics_workspace.test.id
  table_names             = ["Heartbeat"]

  destination_evenhub_id = azurerm_eventhub.test.id
  destination_storage_account_id = 
}

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katbyte , sorry, seems I cannot get your point.

This PR is to support new property destination_metadata not destination_resource_id. May I ask why we have to split the existing property destination_resource_id in this PR because I think they're different things? Does it make sense to implement it in another PR if we intend to split it?

As destination_resource_id already supports Storage Account and EventHub, is there any impact if we don't split destination_resource_id while introducing destination_metadata in this PR?

Do you agree with the part of destination_metadata in this PR?

@neil-yechenwei
Copy link
Contributor Author

@katbyte , thanks for your comments. I've updated code and shared my understanding. Please take another look. Thanks in advance.

@neil-yechenwei neil-yechenwei requested a review from katbyte June 9, 2022 09:20
@katbyte katbyte self-assigned this Jun 27, 2022
}

var eventHubName string
if input.DestinationMetaData.EventHubName != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is destination metadata? is this metadata added to the destination OR is it the final destination for the data?

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's destination metadata. The whole block means the data from all tables in the rule are sent to a specific Event Hub when an Event Hub name is selected. See more details from https://docs.microsoft.com/en-us/azure/azure-monitor/logs/logs-data-export?tabs=portal#create-or-update-data-export-rule.


The `metadata` block supports the following attributes:

* `eventhub_name` - (Optional) The name of the EventHub that is defined for the Log Analytics Data Export Rule.
Copy link
Collaborator

@katbyte katbyte Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well i think that's pretty self explanatory, we should match what the portal is doing. and really. going by these images, maybe have two resources 1 for storage account, 1 for eventhubs - there no metadata in those pages, and the property names are much easier to decipher when correctly named vs being overloaded in the api

@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Jun 28, 2022

@katbyte , Azure portal also allows to set or not set event hub name under destination metadata. So I assume my PR is aligned with Azure Portal. If I am wrong, please correct me.

Currently the destination metadata only supports event hub name. Maybe it would support more metdatas when service team introduces other new destination type in the future.

I already updated the property name and the name description. Seems you're still referencing old commit. Could you refresh the PR to get my latest update?Thanks.

And suggest go thourgh this azure doc (https://docs.microsoft.com/en-us/azure/azure-monitor/logs/logs-data-export?tabs=portal#create-or-update-data-export-rule) and play this log analytics data export rule resource on Azure Portal to better understand the background.

Or if it's possible, could you provide the suggested code/commit for them? Thanks in advance.

image
image

@neil-yechenwei neil-yechenwei requested a review from katbyte June 28, 2022 02:02
@neil-yechenwei neil-yechenwei changed the title azurerm_log_analytics_data_export_rule: support new property metadata azurerm_log_analytics_data_export_rule - support for the destination_metadata property Aug 15, 2022
@neil-yechenwei
Copy link
Contributor Author

As the destination_metadata property has been implemented by another PR and it has been merged, so close this PR.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants