question

ChoudharyRoshankumar-0849 avatar image
0 Votes"
ChoudharyRoshankumar-0849 asked Monalla-MSFT commented

Fetching Application Insights logs from Java code with kusto Query?

Hey Guys,

Need some help here. I am trying to fetch logs from Application Insights using Java ( will use Kusto query) within. Initially I thought I can do this by using Azure Log Analytics API (https://docs.microsoft.com/en-us/azure/azure-monitor/logs/api/overview) however it doesn't have any specific example or maybe I am not looking in the right direction. Also, I did find "Tenant Id" and Client Id "Application Id" but we don't have any client secret as we are using certificates.

Can somebody please help me or point me in the right direction.

I am expecting something like below:

LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
LogsQueryResult queryResults = logsQueryClient.queryWorkspace("{workspace-id}", "kusto query string",
new QueryTimeInterval(Duration.ofDays(1)));

     for (LogsTableRow row : queryResults.getTable().getRows()) {
         System.out.println(row.getColumnValue("TransactionId") + " " + row.getColumnValue("EventReason"));
     }

azure-monitor
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ChoudharyRoshankumar-0849 - Did the below answer help resolve your issue, if not please revert back with any questions.
and if it did, please feel free to "accept as answer" so it can be beneficial to the community.

0 Votes 0 ·
Monalla-MSFT avatar image
0 Votes"
Monalla-MSFT answered Monalla-MSFT edited

Hello @ChoudharyRoshankumar-0849 - Welcome to Microsoft Q&A and thanks for reaching out.

A client secret is a string value your app can use in place of a certificate to identity itself and sometimes called as application password.

Client secrets are considered less secure than certificate credentials. Application developers sometimes use client secrets during local app development because of their ease of use. However, you should use certificate credentials for any of your applications that are running in production.

  • In the Azure portal, in App registrations, select your application.

  • Select Certificates & secrets > Client secrets > New client secret.

  • Add a description for your client secret.

  • Select an expiration for the secret or specify a custom lifetime.

  • Client secret lifetime is limited to two years (24 months) or less. You can't specify a custom lifetime longer than 24 months.

  • Microsoft recommends that you set an expiration value of less than 12 months.

  • Select Add.

  • Record the secret's value for use in your client application code. This secret value is never displayed again after you leave this page.


For application security recommendations, see Microsoft identity platform best practices and recommendations.

Also take a look at this doc for more reference: Add a client Secret

Hope this helps. and please feel free to reach out if you have any further questions.



If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ChoudharyRoshankumar-0849 avatar image
0 Votes"
ChoudharyRoshankumar-0849 answered Monalla-MSFT commented

I did get to know from Andriy Fedonyuk that app Insights API cannot be used with certificates and only option I have is "client_secret". I have to see if that something feasible in our environment.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ChoudharyRoshankumar-0849 - That is correct, like i have mentioned in the answer above client secret is the only option which you can use in place of a certificate to identify itself.

Hope that helps.

If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the above answer so it can be beneficial to the community

0 Votes 0 ·