Logic app "Send Data" to Log Analytics function not working

Oliver Gotz 0 Reputation points
2024-05-07T14:01:29.0633333+00:00

Hello,

I've been having problem with Log Analytics connector that is supposed to send specified data to Log Analytics Workspace.

All access key are correct, all headers, no error codes, logic app is marked as running correctly.

Steps are following:
User's image

  • Event Hub receives log and this trigger checks for certain period for any available logs
  • Send Data sends post request to Log Analytics Workspace which should write down a log

Results (Input/output of Send Data):

User's image

Is there anything I'm missing?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,887 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
564 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 17,881 Reputation points
    2024-05-08T06:00:20.05+00:00

    @Oliver Gotz Thanks for reaching out. I have tried to reproduce your issue with sample data generated in event hub. Here are steps I have followed as well as modifications done to make sure data is inserted into logic app.

    1. Created EventHub, Logic App and Log analytic workspace. Within log analytics workspace , created a custom log by uploading sample.txt.
    2. I have created below code for retrieving the data from event hub and send it to log analytics workspace.
         {
             "definition": {
                 "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                 "actions": {
                     "Compose": {
                         "inputs": "@triggerBody()?['ContentData']",
                         "runAfter": {},
                         "type": "Compose"
                     },
                     "Send_Data": {
                         "inputs": {
                             "body": "@{json(outputs('Compose'))}",
                             "headers": {
                                 "Log-Type": "EventHubData_CL"
                             },
                             "host": {
                                 "connection": {
                                     "name": "@parameters('$connections')['azureloganalyticsdatacollector']['connectionId']"
                                 }
                             },
                             "method": "post",
                             "path": "/api/logs"
                         },
                         "runAfter": {
                             "Compose": [
                                 "Succeeded"
                             ]
                         },
                         "type": "ApiConnection"
                     }
                 },
                 "contentVersion": "1.0.0.0",
                 "outputs": {},
                 "parameters": {
                     "$connections": {
                         "defaultValue": {},
                         "type": "Object"
                     }
                 },
                 "triggers": {
                     "When_events_are_available_in_Event_Hub": {
                         "evaluatedRecurrence": {
                             "frequency": "Second",
                             "interval": 3,
                             "timeZone": "India Standard Time"
                         },
                         "inputs": {
                             "host": {
                                 "connection": {
                                     "name": "@parameters('$connections')['eventhubs']['connectionId']"
                                 }
                             },
                             "method": "get",
                             "path": "/@{encodeURIComponent('test')}/events/batch/head",
                             "queries": {
                                 "consumerGroupName": "$Default",
                                 "contentType": "application/json"
                             }
                         },
                         "recurrence": {
                             "frequency": "Second",
                             "interval": 3,
                             "timeZone": "India Standard Time"
                         },
                         "splitOn": "@triggerBody()",
                         "type": "ApiConnection"
                     }
                 }
             },
             "parameters": {
                 "$connections": {
                     "value": {
                         "azureloganalyticsdatacollector": {
                             "connectionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Web/connections/azureloganalyticsdatacollector",
                             "connectionName": "azureloganalyticsdatacollector",
                             "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Web/locations/eastus/managedApis/azureloganalyticsdatacollector"
                         },
                         "eventhubs": {
                             "connectionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/rg/providers/Microsoft.Web/connections/eventhubs",
                             "connectionName": "eventhubs",
                             "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Web/locations/eastus/managedApis/eventhubs"
                         }
                     }
                 }
             }
         }
      

    When I sent the data directly from event hub , in the first attempt, the data wasn't inserted. Upon checking, the input value isn't converted to json. I would suggest you check and convert your data to json by using json() builtin function.