📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Your team needs a central place for logs from a set of .NET 10 services on Azure. Compare Application Insights with Log Analytics, Seq, the ELK stack or OpenSearch, and Grafana Loki. How do they store and index logs, what do they cost to run and retain, and how would you choose?

Compares the main log platforms for .NET teams (Application Insights and Log Analytics, Seq, Elasticsearch/OpenSearch, Grafana Loki) on storage and indexing model, query language, licensing, cost drivers, retention tiers and Australian data residency, and how to choose.

Intermediate Theory Intermediate application-insights elasticsearch grafana-loki log-management observability seq

🎯 Key points

  • Log Analytics (behind workspace-based Application Insights) indexes everything and is queried with KQL; cost is driven by GB ingested, with Analytics, Basic and Auxiliary table plans
  • Seq is a self-hosted structured-log server built around Serilog/OTLP; free Individual licence for one user, paid tiers for teams
  • Elasticsearch/OpenSearch build an inverted index on fields: fast full-text search, but heavy on storage, memory and operations
  • Grafana Loki indexes only labels and stores compressed log chunks in object storage: cheap at volume, but queries scan and high-cardinality labels hurt
  • Every option depends on structured logs (message templates, consistent property names) to be queryable
  • Cost drivers: ingestion volume, index size, retention period and query scans; estimate GB/day before choosing
  • Ship via OpenTelemetry (OTLP) so the backend can change without touching application code
  • Retention by data class and Australian data residency (Australia East/Southeast) for Privacy Act obligations

⏱ 30-second answer

All four store structured logs and let you search them, but they differ in how much they index, which drives cost.

  • Application Insights / Log Analytics: fully managed, indexes every field, queried with KQL, correlated with traces and metrics. You pay per GB ingested; Basic and Auxiliary table plans and archive cut the cost of noisy or long-retention data.
  • Seq: small, self-hosted, excellent developer experience for structured logs; free for one user.
  • Elasticsearch / OpenSearch: inverted index on fields, powerful full-text search, but you run (or pay for) a memory-hungry cluster.
  • Grafana Loki: indexes only labels, stores chunks in object storage: cheapest at high volume, slower for free-text searches.

I choose by team size, volume, existing cloud and who runs it, and I ship logs with OpenTelemetry so the choice stays reversible. The trade-off is index everything and query fast versus index little and pay less.

🗣 Full answer (senior)

How I would answer this in an interview

"The first thing I look at is how each platform indexes data, because that decides both the query experience and the bill. Log Analytics, which sits behind workspace-based Application Insights, ingests every field into columnar tables and lets you query with KQL; you pay mainly per GB ingested, and there are cheaper Basic and Auxiliary table plans plus long-term retention for data you rarely query. Elasticsearch and its fork OpenSearch build an inverted index on fields, so full-text search is fast, but the index costs disk, heap and someone to run the cluster. Grafana Loki goes the other way: it indexes only a few labels like service and environment, stores compressed chunks in object storage, and greps the chunks at query time. Seq is a single, self-hosted server that is lovely for structured logs from Serilog or OTLP and free for one user.

For a .NET team already on Azure, I usually start with Application Insights through the Azure Monitor OpenTelemetry distro, because logs, requests, dependencies and traces share an operation id and I get alerts and workbooks for free. I'd use Seq for local development and small internal systems, Loki when we already run Grafana and Kubernetes and volume is high, and Elastic or OpenSearch when the organisation already has a search cluster or needs heavy full-text analytics. Whatever we pick, the services emit through OpenTelemetry, so switching backends is a collector change, not a code change.

The mistake I see is choosing on features and discovering the cost later: a chatty Information log at 2,000 requests per second is tens of GB a day. A senior answer is that the platform matters less than what you send to it and how long you keep it."


How each platform stores logs

Platform Storage and index Query language Who runs it Licence (as of late 2026)
Application Insights / Log Analytics Columnar tables, every column queryable KQL Microsoft (PaaS) Commercial, pay per GB
Seq Embedded storage with indexes on properties Seq query language (SQL-like) You Commercial; free Individual licence for one user
Elasticsearch Inverted index per field (Lucene) Query DSL, ES QL, KQL-style Kibana queries You or Elastic Cloud AGPL v3 option added in 2024, alongside SSPL and Elastic Licence
OpenSearch Inverted index (Lucene fork) DSL, PPL, SQL You or AWS OpenSearch Service Apache 2.0, governed by the OpenSearch Software Foundation (Linux Foundation)
Grafana Loki Labels indexed; log lines in compressed chunks in object storage LogQL You or Grafana Cloud AGPL v3

Where the money goes

Cost driver Log Analytics Elastic / OpenSearch Loki
Ingestion Per GB (cheaper for Basic/Auxiliary tables) CPU to index Low, no full index
Storage Free interactive window, then per GB per month; long-term retention up to 12 years Index is often 1-1.5x raw size, on fast disk Object storage, cheap
Querying Free for Analytics tables, billed for Basic/Auxiliary Cluster capacity Scans chunks, so wide queries are slow
Operations None High: shards, heap, upgrades Medium

When to use / when not

Choice Fits Avoid when
Application Insights Azure-hosted .NET, small platform team, need correlation and alerts Very high volume of low-value logs with no sampling or table plans
Seq Dev machines, small teams, on-premises apps Large multi-team estate needing RBAC at scale and long retention
Elastic / OpenSearch Existing cluster, heavy full-text and security analytics No one to own the cluster
Loki Kubernetes plus Grafana, high volume, label-driven queries You need fast free-text search across months

Production example

A team of [12] services sent about [40 GB/day] of logs to Log Analytics, 70% of it Information-level HTTP noise. We moved the noisy container stdout table to the Basic plan, kept AppRequests, AppExceptions and audit events on Analytics, and set 30 days interactive with 1 year of long-term retention for audit. Ingestion cost dropped by about [55%] without losing anything we had queried during the previous six months of incidents.

🔍 What the interviewer is checking

Checks whether the candidate understands how log platforms differ underneath and can choose on cost, operations and risk rather than familiarity.

Green flags

  • Explains full index vs columnar vs label-only storage and what it means for cost.
  • Mentions ingestion volume, retention tiers and table plans.
  • Decouples apps from the backend with OpenTelemetry.
  • Raises data residency and personal information in logs.

Red flags

  • "We just use whatever is installed" with no cost awareness.
  • Thinks more logs is always better.
  • No idea who would operate a self-hosted cluster.

📚 Learn in depth

1. Three ways to store logs

Full index (Elastic/OpenSearch)       Columnar (Log Analytics)          Label index (Loki)
-------------------------------       -------------------------         ------------------
"order 42 failed" ->                  | Time | Svc | Level | Msg |       {svc="orders",env="prod"}
  term index: order->doc1             | ...  | ... | ...   | ... |          -> chunk1.gz, chunk2.gz
              failed->doc1            columns compressed, scanned           grep at query time
fast term lookup, big index           fast aggregations                     tiny index, cheap storage
  • An inverted index maps each term to the documents that contain it, so failed AND order is a set intersection. The price is storage and heap, and mapping explosions when every log has different property names.
  • Columnar tables (Log Analytics runs on Azure Data Explorer technology) compress each column and are excellent at summarize count() by bin(TimeGenerated, 5m).
  • Label-only indexes keep the index tiny. Loki's rule is a handful of low-cardinality labels; putting a user id in a label creates millions of streams and breaks it.

2. How .NET logs get there

ILogger<T> --> OpenTelemetry logging provider --> OTLP --> Collector --> backend(s)
     |                                                     |
     +--> Serilog sinks (Seq, Elastic) [alternative]       +--> Azure Monitor exporter

In .NET 10, ILogger plus the OpenTelemetry provider is the vendor-neutral path. The Azure Monitor OpenTelemetry distro (Azure.Monitor.OpenTelemetry.AspNetCore) is Microsoft's recommended way for new apps; the Application Insights SDK 3.x (released early 2026) also runs on OpenTelemetry under the hood for apps that still use TelemetryClient. Do not mix the 3.x SDK and the distro in one app.

3. Log Analytics table plans

Plan Use for Query Free interactive retention
Analytics Data you alert on and query often Full KQL, free queries 31 days (90 with Sentinel)
Basic High-volume troubleshooting data KQL, queries billed per GB scanned 30 days
Auxiliary Verbose, rarely read, compliance Slower, billed queries 30 days

All plans can keep data in long-term retention for up to 12 years. Check which tables support which plan before designing around it.

4. Data residency and privacy

Logs often hold personal information by accident (emails, IP addresses, names in exception messages). Under the Privacy Act 1988, APP 11 requires reasonable steps to protect it and to destroy it when no longer needed, and a leaked log store can be a notifiable data breach. Keep the workspace in Australia East or Southeast, mask at source and set retention per data class rather than one long default.

5. Estimating volume

requests/s x log lines per request x bytes per line x 86,400
= 500 x 6 x 600 B x 86,400 ~= 155 GB/day

That arithmetic, done before go-live, is what stops the end-of-month surprise.

Try it yourself

  1. Run Seq in Docker (datalust/seq), point an ASP.NET Core app at it with the OTLP exporter and query by a property.
  2. In a Log Analytics workspace, run Usage | where TimeGenerated > ago(30d) | summarize GB = sum(Quantity) / 1024 by DataType | order by GB desc to see which tables cost the most.
  3. Run Loki and Grafana with Docker Compose, add a high-cardinality label on purpose, and watch the stream count grow.
  4. Estimate daily volume for your own service with the formula above and compare it with what the platform reports.

💻 Code

Sending ILogger output through OpenTelemetry so the backend is a configuration choice, not a code change:

// Program.cs (.NET 10)
using Azure.Monitor.OpenTelemetry.AspNetCore;
using OpenTelemetry.Logs;

var builder = WebApplication.CreateBuilder(args);

var backend = builder.Configuration["Observability:Backend"]; // "AzureMonitor" or "Otlp"

if (backend == "AzureMonitor")
{
    // Logs, traces and metrics to Application Insights (connection string from config/Key Vault)
    builder.Services.AddOpenTelemetry().UseAzureMonitor();
}
else
{
    // Seq, Loki (via a collector), Elastic or OpenSearch all accept OTLP
    builder.Logging.AddOpenTelemetry(o =>
    {
        o.IncludeFormattedMessage = true;
        o.IncludeScopes = true;
        o.AddOtlpExporter(); // endpoint from OTEL_EXPORTER_OTLP_ENDPOINT
    });
}

var app = builder.Build();
app.MapGet("/orders/{id:int}", (int id, ILogger<Program> logger) =>
{
    logger.LogInformation("Fetched order {OrderId}", id); // structured: OrderId becomes a column/field
    return Results.Ok(new { id });
});
app.Run();
// Which tables cost the most in the last 30 days (Log Analytics)
Usage
| where TimeGenerated > ago(30d) and IsBillable
| summarize GB = sum(Quantity) / 1024 by DataType
| order by GB desc

⚠ Common mistakes

  • Mistake: Choosing a platform on features alone. Why it is wrong: Each platform prices a different thing (GB ingested for Log Analytics, cluster size for Elastic/OpenSearch, object storage plus query compute for Loki), and a busy API can produce tens of GB a day, so the cheapest platform at 1 GB/day can be the most expensive at 100 GB/day. Instead: Estimate volume (requests/s x lines per request x bytes per line x 86,400), then compare ingestion, retention, query and people costs over a year at that volume and at 3x growth.
  • Mistake: One retention period for everything. Why it is wrong: Debug noise kept for two years costs money and increases privacy risk. Instead: Set retention per table or data class: short for diagnostics, long and cheap for audit.
  • Mistake: Writing straight to a vendor SDK from every service. Why it is wrong: Switching platforms means touching every codebase. Instead: Use ILogger with OpenTelemetry and route through a collector or distro.
  • Mistake: Unstructured, interpolated log messages. Why it is wrong: No platform can filter or aggregate on values buried in free text, so every query becomes a slow regex. Instead: Use message templates with consistent property names across services.
  • Mistake: Putting user ids or order ids into Loki labels. Why it is wrong: Each label value creates a stream, and high cardinality degrades the index and queries. Instead: Keep ids in the log body or structured metadata and use few, low-cardinality labels.
  • Mistake: Self-hosting Elasticsearch without an owner. Why it is wrong: Shard sizing, heap tuning and upgrades become a part-time job, and a full disk silently drops logs. Instead: Use a managed service or a simpler platform if nobody owns the cluster.
  • Mistake: Storing logs outside Australia without checking obligations. Why it is wrong: Logs often contain personal information covered by the Privacy Act and customer contracts. Instead: Use Australia East/Southeast regions and mask personal data at source.

🏛 Senior insight: trade-offs

Seniors treat the log platform as a cost, risk and people decision, not a tooling preference. The questions are how much you index, how long you keep it, who operates it, and whether the team will actually use it at 3 am. A platform the team already knows (KQL for an Azure shop, Kibana for a team with an Elastic history) usually beats a technically better one nobody can query under pressure. I involve the people who will live with it (on-call engineers, security, finance) and record the choice in an ADR with the volume estimate it was based on, so it can be revisited when volume changes.

Option When it fits Cost profile When not to
Application Insights + Log Analytics Azure, small platform team, want correlation and alerts out of the box Per GB; table plans and long-term retention help Unfiltered high-volume logs with no budget
Seq Dev, small teams, on-premises Cheap licence, one VM Large estates needing scale and fine RBAC
Elastic / OpenSearch Existing cluster, full-text and SIEM-style analytics Infrastructure and people No owner
Loki Kubernetes + Grafana, high volume Object storage, cheap Frequent free-text searches over long ranges
Retention and query behaviour Log Analytics Seq Elastic / OpenSearch Loki
How retention is set Per table: interactive period plus long-term retention up to 12 years Retention policies by age and filter; storage-limited on the Individual licence Index lifecycle policies (hot, warm, cold, delete) Per tenant or stream retention in object storage
Query speed on old data Long-term retention needs search jobs or restore (slower, billed) Same as recent data while stored Slower on cold/frozen tiers Same scan cost, grows with range
Effect of longer retention Linear storage cost Disk on your server Disk and shard count, can hurt cluster health Cheap object storage

Most of the saving comes from sending less (levels, sampling, dropping health-check noise) and tiering retention, not from changing vendor. I measure the decision with the Usage table (or equivalent ingestion metrics): GB per day per service, and which tables were actually queried in the last 90 days.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions Serilog sinks or the OpenTelemetry provider Why: Checks how the app side of logging plugs into the chosen platform
    How to answer

    Your code always logs through ILogger<T>; the choice is what sits underneath.

    • Serilog replaces the provider pipeline (AddSerilog). Destinations are sinks (Seq, files, Elastic, OTLP); enrichers add properties such as machine name or user id. It has rich destructuring and a bootstrap logger for start-up failures.
    • NLog (UseNLog) uses targets and layouts, configured in nlog.config, popular in older enterprise estates.
    • Built-in + OpenTelemetry: AddOpenTelemetry().WithLogging() exports to OTLP or Azure Monitor, with logs correlated to traces and metrics.

    For a new .NET 10 service on Azure I'd start with built-in + OpenTelemetry; I'd keep Serilog or NLog where a team already relies on their sinks. The trade-off is fewer moving parts versus richer formatting and sink choice.

  2. When: Candidate mentions ingestion cost or retention tiers Why: Checks cost control once logs are flowing
    How to answer

    First measure, don't guess: in Log Analytics run union * | summarize sum(_BilledSize) by itemType, then break traces down by category and message template (OriginalFormat). One or two sources usually dominate: a Debug level left on, EF Core SQL command logging, HTTP body logging, health probes, or two pipelines sending the same data.

    Latency rises because logging runs on the request thread: synchronous sinks, a full console queue, or formatting large payloads.

    Fix in order: levels per category (configuration, no deploy), remove duplicates and noise, sample traces while keeping metrics complete, then workspace controls: daily cap as a safety net, cheaper table plans, retention, and a cost anomaly alert. The trade-off: every gigabyte you cut must not be the one you need at 3 a.m.

  3. When: Candidate mentions querying logs by property Why: Checks why structured properties make logs queryable
    How to answer

    Structured logging records an event: a constant message template plus named properties, instead of a pre-built string. In logger.LogInformation("Order {OrderId} placed in {ElapsedMs} ms", id, ms), the provider gets the template and the values separately, so OrderId and ElapsedMs become queryable fields (Application Insights customDimensions, OpenTelemetry attributes, Seq properties).

    With string interpolation ($"Order {id} placed") the provider only sees a finished string: no properties, a different message every time, and the string is built even when the level is disabled. Analyser CA2254 warns about this.

    The trade-off: templates take discipline in naming, but they turn logs from text you grep into data you can filter, group and alert on.

🛠 Real-world problems: how you handle them

Moving noisy logs to cheaper tiers without losing incident data
Situation
[12] .NET services on Azure Container Apps sending about [40 GB/day] to one Log Analytics workspace in Australia East; the monthly bill had become the platform team's biggest line item.
Signals
Azure Cost Management showed Log Analytics ingestion as [60%] of observability spend; the Usage table showed ContainerAppConsoleLogs and AppTraces as the top tables.
Investigation
Queried `Usage` by DataType, then sampled the top tables with KQL to see what the lines were (health-check and HTTP request logs at Information). Checked LAQueryLogs to see which tables were queried during the last six months of incidents.
Resolution
Immediate: filtered health-check request logs at the OpenTelemetry Collector and raised the Microsoft.AspNetCore category to Warning. Long-term: moved console logs to the Basic plan, kept requests, exceptions and audit events on Analytics, and set retention per table.
Prevention
A daily ingestion alert per table routed to the platform channel, a log budget per service reviewed in the monthly ops review, and an ADR recording retention per data class.

How to tell it (STAR)

**S:** Our [12] services were sending around [40 GB] of logs a day and the bill was the platform's largest cost. **T:** I was asked to cut it without hurting incident response. **A:** I used the Usage table to find the top tables, then checked LAQueryLogs to see what we actually queried in incidents. I dropped health-check noise at the collector, raised framework log levels, moved console logs to the Basic plan and set retention per data class. **R:** Ingestion cost fell by about [55%], and in the next [three] incidents we never needed data we had dropped.

↩ Usually asked after

More in Log Management

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me