How to Connect Power BI to Log Analytics
Connecting Azure Log Analytics to Power BI transforms your raw, text-based log data into interactive and easy-to-understand visuals. This allows you to build custom dashboards, track key metrics, and share insights with your team without requiring everyone to learn Kusto Query Language (KQL). This tutorial will walk you through the exact steps to connect these two powerful tools, export your query, and start building insightful reports today.
Why Connect Log Analytics to Power BI?
While the Log Analytics interface in the Azure portal is great for ad-hoc querying, it's not designed for building shareable, long-term business dashboards. Connecting its data to Power BI unlocks a new level of reporting capabilities.
- Create Custom Dashboards: Build reports that display your most important metrics at a glance, from application performance and user activity to security events and infrastructure health.
- Combine Data Sources: Merge your log data with other business data. For example, you can combine application performance metrics from Log Analytics with sales figures from your CRM to see how website speed impacts revenue.
- Automate Reporting with Scheduled Refreshes: Set your Power BI reports to refresh automatically on a schedule (e.g., daily or hourly), ensuring your team always has the latest information without any manual work.
- Share Insights Easily: Distribute polished, interactive reports to stakeholders who don’t have access to the Azure portal or the technical skills to write KQL queries.
Prerequisites: What You’ll Need
Before you get started, make sure you have the following in place:
- An active Azure subscription: You'll need access to an Azure account where your resources are located.
- A Log Analytics workspace: This workspace should be collecting data from your Azure resources, such as virtual machines, web apps, or other services.
- Power BI Desktop: You'll need the free Power BI Desktop application installed on your computer. You can download it directly from Microsoft.
- Proper Permissions: The account you use to sign in must have at least the "Log Analytics Reader" role for the specific workspace you want to query. This ensures you have permission to access the data.
Step-by-Step Guide: Connecting Power BI to Log Analytics
The most straightforward method for connecting Log Analytics to Power BI involves exporting a pre-written KQL query, which Power BI then uses to fetch data. This ensures your query is working correctly in Azure before you bring it into Power BI.
Step 1: Write and Test Your KQL Query in Azure
First, you need to decide what data you want to pull into Power BI. You do this by writing a Kusto Query Language (KQL) query. It’s always best practice to write, run, and refine your query directly in the Log Analytics workspace first.
- Navigate to your Log Analytics workspace in the Azure portal.
- Click on Logs in the left-hand navigation pane to open the query editor.
- Write your query. For this example, let's use a simple query that counts the number of application requests grouped by result code over the past seven days.
AppRequests | where TimeGenerated > ago(7d) | summarize RequestCount = count() by bin(TimeGenerated, 1d), ResultCode
- Run the query to make sure it returns the data you expect. Once you're happy with the results, you're ready to export it.
Step 2: Export the Query for Power BI
Azure makes this step incredibly simple by generating the exact code that Power BI needs to understand your request.
- With your query results showing in the Log Analytics editor, click the Export button near the top right of the query editor.
- From the dropdown menu, select Export to Power BI (M Query).
This will download a small text file (typically named PowerBIQuery.txt) to your computer. This file contains a Power Query M formula, which is the scripting language Power BI uses for data connections and transformations.
Step 3: Import the M Query into Power BI Desktop
Now, it's time to open Power BI Desktop and a new, blank report. This is where you'll paste the M query you just downloaded.
- In Power BI Desktop, go to the Home tab and click Get Data.
- From the list of common data sources, select Blank query and click Connect. This will open the Power Query Editor in a new window.
- In the Power Query Editor window, click on Advanced Editor in the Home tab.
- A new window will pop up showing some default M code. Delete all of the text in this window.
- Open the
.txtfile you downloaded from Azure, copy its entire contents, and paste it into the now-empty Advanced Editor window in Power BI. - Click Done.
Power BI will now prompt you to sign in to authenticate your access to your Azure data. You may need to select "Organizational account" and sign in with the same credentials you use for the Azure portal. Once authenticated, Power BI will run the query and show you a preview of your data.
Step 4: Load and Visualize Your Data
Once you see the data preview in the Power Query Editor, you’re connected! From here, you can perform any additional transformations if needed, such as changing data types or renaming columns.
When you're ready, click Close & Apply in the top-left corner of the Power Query Editor. Your Log Analytics data will be loaded into your Power BI report model.
You can now find your data fields in the Data pane on the right-hand side of the Power BI window. Just drag and drop these fields onto the report canvas to start building visuals like line charts, bar charts, and tables.
Alternative Method: Using the Azure Monitor Logs Connector
While the export method is often easiest, you can also connect directly from Power BI using a built-in connector.
- In Power BI Desktop, go to Get Data.
- In the search box, type "Azure" and select Azure Monitor Logs from the list, then click Connect.
- You'll be prompted to enter your Workspace ID and other details. You can find your Workspace ID on the Overview page of your Log Analytics workspace in the Azure portal.
- The next screen will provide a box where you can directly paste your KQL query and set a time range.
This method accomplishes the same goal but requires you to find and enter connection details manually. Many people find the "Export to Power BI" workflow faster, especially when iterating on queries in the Azure portal.
Practical Tips for a Smooth Connection
Keep these tips in mind to avoid common issues and ensure your reports perform well.
- Optimize KQL Queries First: Power BI performance is directly tied to your query performance. Log data can be immense, so avoid pulling raw, unfiltered data. Use KQL to aggregate and summarize data on the Azure side before it gets to Power BI. Filter early with
whereclauses and only select the specific columns you need. - Don't Pull Too Much Data: Power BI is a visualization tool, not a data warehouse for raw logs. Your goal should be to bring in pre-aggregated summary data. For example, instead of pulling every single request log, use
summarizeto get the count of requests per hour. This will make your report much faster and more responsive. - Set Up Scheduled Refresh: After publishing your report to the Power BI Service (app.powerbi.com), you'll need to configure a scheduled refresh to keep it up-to-date. Navigate to your dataset’s settings, enter your Azure credentials again, and set a refresh schedule. This automates the entire reporting process for you.
Example: Creating a Website Performance Report
Let's tie it all together with a quick, practical example.
Goal: Create a simple dashboard showing the average request duration and the number of failed requests for a web app over the past 30 days.
1. The KQL Query
In Log Analytics, you would write a query like this:
AppRequests | where TimeGenerated > ago(30d) | summarize AverageDurationMs = avg(DurationMs), FailedRequestCount = countif(Success == false) by bin(TimeGenerated, 1d) | order by TimeGenerated asc
2. Export and Import
You would then use the "Export to Power BI (M Query)" feature, and paste this M query into the Advanced Editor of a blank query in Power BI Desktop.
3. Build the Visuals
Once the data is loaded, you could build:
- A line chart with
TimeGeneratedon the axis andAverageDurationMsas the value to track performance trends. - A card visual to display the total
FailedRequestCountas a key performance indicator (KPI). - A bar chart to show the count of failed requests per day.
Within minutes, you've gone from a raw log table to a useful, interactive dashboard that clearly communicates the performance of your web application.
Final Thoughts
Turning Azure log data into clear, actionable insights is a powerful move, and connecting Log Analytics to Power BI is a fantastic way to do it. By crafting your KQL query in Azure, exporting it for Power BI, and loading it into your report, you can build meaningful, automated dashboards that empower your team to make better decisions.
Of course, building and maintaining these connections still involves bouncing between platforms and managing refresh schedules. This is the exact kind of manual drudgery we built Graphed to eliminate. We enable you to connect your data sources in a few clicks and then build reports and dashboards simply by describing what you want to see in plain English. Instead of writing KQL and configuring data pipelines, you can just ask questions and get real-time, interactive dashboards built for you automatically.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?