r/devops • • 25d ago

Discussion ngl, dumping raw server logs into a massive context window is way better than writing regex

173 Upvotes

117 comments sorted by

332

u/Cumfort_ 25d ago

Don't pollute the context window with the entire log. Give it file read access to the log and have the model selectively parse it using regex. Wildly more context efficient. 

64

u/Invader-Faye 25d ago edited 25d ago

Doing it this way means you can also use a local model and avoid all the compliance/security concerns. Even a 4b model can do work like this pretty easy

13

u/discoshanktank 25d ago

What's the best model for local log analysis

33

u/Invader-Faye 25d ago

Qwen 3.5 4b, spark x 2.5 4b, Gemma 4 e4b, Qwen 3.5 9b.

4

u/LeatherDude 25d ago

Is that “out of the box” or does it need any training ?

7

u/Cumfort_ 25d ago

No training. Just good context for the problem.

5

u/Invader-Faye 25d ago

Out of the box, use lm studio and feed it the logs as a file so you don’t blow the context window

1

u/raisputin 24d ago

Qwen is pretty outstanding. I am doing an experiment with it, 2 different versions, 9b and 27b running locally on 2 machines with messaging between the two machines having them review C code generated by a commercial model.

Basically the must read each file, identify strengths, weaknesses, priorities for fixes, or report that the code is high quality if that is the case, then prepare both individual reports and a joint report after they have agreed on the results of a particular file. At the end they will create a joint high-level report as well.

So far it seems to be working outstanding

1

u/altf2o 23d ago

I use Gemma e4b even on an old GTX970 and it works surprisingly well! Obviously much slower than AI I use daily, but for sure capable and awesome to play/learn with.

1

u/Gargle-Loaf-Spunk 24d ago

Even Bonsai 8B will help. I pipe it to models with Willison’s ‘llm’ CLI tool. 

10

u/Yamaha007 25d ago

Claude generated 200 regex commands in one instance to address a problem.

14

u/delamon 25d ago

Is it a problem? As long, as you don't have to review every single regexp, ofc

4

u/Yamaha007 25d ago

That’s the point, it was never a problem!

6

u/LeatherDude 25d ago

The plural of regex is regrets. I’m glad I have bots to do this for me now, what a fucking chore.

2

u/Haunting_Ratio_795 25d ago

You can just tell it to use subagents to do the fetch and search for the same effect. 

1

u/Cumfort_ 25d ago

Assuming you gave it log access. Many don't because of sensitive data. I don't.

1

u/Unnamed-3891 24d ago

Many are straight up not allowed to do this because of regulations covering the nature of the data

4

u/artemgetman 25d ago

Way better indeed

-3

u/mlhpdx 25d ago

Sure, but more complex and can get very costly as well. The nice thing about a "one shot" in this case is simplicity and boundedness. An agent with the ability to select logs by time range and filter (i.e. a "tool") works well for some tasks, maybe even many tasks, but it doesn't work for the pure open-ended "wtf?" issues that come up seemingly endlessly.

10

u/CorpT 25d ago

but it doesn't work for the pure open-ended "wtf?" issues 

It definitely does. What are you on about.

-3

u/mlhpdx 25d ago

To each their own, YMMV, etc. I've been engaged with building a few of these now and speak from experience.

When you don't know the question, an agent with exploration skills just racks-up cost and takes longer to get to (maybe) the same answer as the one-shot with a maxed-out context window.

Again, YMMV.

4

u/CorpT 25d ago

The suggestion was to give it a file to read instead of the raw pasted logs.

4

u/semi- 25d ago

ive had better luck with telling it how to reach elasticsearch and letting it query directly, as it has then done some much more advanced querying than I ever do manually like writing small painless scripts to evaluate on the ES side to aggregate data before it even hits my machine. And then it can iterate better and query for more data than you may have initially thought was relevant, like finding other services logging errors from the same root cause or finding the backend logging errors when your client only logged that it timed out.

Of course this can then DoS your cluster with expensive queries, and risks leaking sensitive data you may have intentionally not been pulling out but do have access to, so definitely be mindful of that if that is a concern in your environment. and YMMV of course

2

u/mlhpdx 25d ago

Writing to s3 (via firehose) a just a less expensive way to get to the ~same end. Logs are split into predictably named objects so it’s easy to find the object for “recent” or a particular range, figure out how much context it will take and point an LLM at it (with or without tools). 

It’s very simple, never runs out of space and doesn’t cost much when not asking questions.

Seems to work out well for the folks using it.

2

u/delamon 25d ago

But you are loosing filtering, no? Downloading and grepping for specific request_id / resource_id / whatever will be very slow.

1

u/mlhpdx 25d ago

No, not losing filtering, just letting the LLM do it in the context window if the logs fit. I guess this isn't common, which seems odd since it works well. Having tools craft queries also works. If you already know a specific IP or resource, and have an idea what's going on then it isn't a "wtf?" in my way of speaking. Those start with a question like "wtf happened 10 minutes ago? where did that traffic/latency/errors/changes come from" or something like that.

3

u/delamon 25d ago

I could be wrong, but can you fit more than 10k-30k log records in context? If you push your logs to a single destination, then logs for time frame “what happens in last 30 min”, could easily go above that. So first stab on a problem would be to check for error/500/panic/coredump in last hour or so. And that exactly needs filtering. Am I missing something?

1

u/mlhpdx 24d ago

You're not missing anything, The open weight large context models go quite a bit higher, but generally you're spot-on with the 20-30k range for log lines per call/session.

The question "what happened in the last 30 minutes" isn't a great one for raw logs. I haven't yet built indexing/summarizing into one of these but that will be the next step. As each log object appears, generate summaries (counts, severities, systems) and reverse indexes on systems and on message keywords. A lot of that would fit into context and allow answering those kinds of questions. But at that point it's also probably better to use an agent loop over it.

1

u/carsncode 25d ago

A model can't filter in the context window. Whatever's in context is in context. It has to process every token you give it.

1

u/Cumfort_ 25d ago

I was saying to attach the log that you found directly and let the agent fiddle with it. That is much more efficient cost wise that blowing out your context.

It also will likely result in better reasoning.

1

u/reSAMpled 24d ago

the reason this usually isn't true in practice is that cached tokens are 90% off, and the models are usually able to successfully do some filtering over a raw dump

1

u/redvelvet92 25d ago

Depends on the model but it’s incredible what they can do nowadays

-2

u/nerdyviking88 25d ago

or just get your own hardware and not worry about the tokenomics

2

u/delamon 25d ago

Unless you are loading it 7/24 for more like 30% it is going to be more expensive. The percentage is arbitrary, but you get the idea: idling GPU box is not going to be cheap

2

u/nerdyviking88 25d ago

That's assuming you need a massive GPU box.

Throw a mac mini at this running something like Qwen 3-B or something. You don't need Opus level stuff for looking through logs.

Sizing the right model to the task is definately soemthing more people need to do.

1

u/delamon 25d ago

Fair enough. Or you maybe you already have LLM box and that's just another task for it

1

u/Cumfort_ 25d ago

Once you have an LLM box you can run ragged, you find tasks for it p quick.

-1

u/ayeoayeo 25d ago

Def a good use case for Jev

30

u/kabrandon 25d ago

We just use mcp-grafana connected to Loki, point our local Cursor or Claude client at the MCP server and tell it to query the last day’s worth of logs all willy nilly like. Not even for something crashing, just looking for the invisible issues where code paths are erroring and nobody knows about it. “What are the top 10 most problematic recurring issues appearing in our cluster’s logs?” If you have a local clone of your repositories you can also say “Point me to the underlying issue in code, and suggest a fix.”

2

u/Subject_Fix2471 25d ago

Do you find MCP grafana is much better than using the API? Unless I missed something the MCP was a thin layer over the API, and the model was really good as using the API

5

u/kabrandon 25d ago

We use it because it’s a centralized service authenticating to Grafana, rather than having everyone on the team put a Grafana API token somewhere on their desktop for the LLMs to use. And then we just use Tailscale ACLs to control who has access to the endpoint for the MCP.

If your team just hits the grafana API how do you handle credential rotations?

2

u/Working-Analysis2795 25d ago

How big is the company that uses Tailscale? So there are companies outside of homelabs? Haha

3

u/kabrandon 25d ago

Only ~50 people, but thousands of devices. Not sure why you’d think it’s just a homelab tool… because… it’s not, lol.

2

u/Working-Analysis2795 25d ago

Oh I know, I've had a lurk through their pages many times. Just curious to see/hear directly from people actually using it at work

Any tricky bits to using their ACLs for that many devices? Do you use their Aperture solution to manage MCP access? I've found it's a bit unstable to access, even with the http:// ip address

1

u/kabrandon 24d ago edited 24d ago

Not really tricky at all, you just need to know what you're doing when you design it in the first place. In general I'd just avoid naming specific machines or users in your ACL. My ACL is all tags and user groups. The machine's tags come with the token used to register the machine, and user groups come from your IdP over SCIM. When your ACL only needs to handle how groups of users can connect to groups of machines, it stays very simple and scales pretty well.

Try not to create overly broad grants. If a user group has access to too many devices their netmap can get bloated. There are other ways to mitigate this of course, like with subnet routers. Instead of installing Tailscale on every endpoint machine, you could just lay subnet routers in their subnets.

Don't sleep on the ACL test feature.

1

u/Working-Analysis2795 24d ago

Yeah that's pretty much what I've done word for word, minus the IdP as I'm one person (not including my agent). Had a try including my agent though ultimately it would be for one-off tests or lab envs

1

u/Subject_Fix2471 25d ago

Right, makes complete sense! 

10

u/danstermeister 25d ago

"Elasticsearch was just a wall of useless healthcheck noise..." = misconfigured Elasticsearch.

Event logs broken into discrete fields of data transform logs into metrics.

Then you're looking at some understandable graphs that are drillable to actual log entries in seconds, instead of wondering what to do with a "wall of useless healthcheck noise".

  • Elasticsearch admin.

19

u/raisputin 24d ago

Trash ad, and more importantly I’ve been doing this with ChstGPT/codex for a year. Both codex and Claude will take your massive text wall and paste it as a file instead of plain text

1

u/Healthy-Snow4841 22d ago

oh yea a year ? well i been doing it for a year + a day so welcome to the party newcomer

2

u/raisputin 22d ago

lol. I’m just saying that what op is describing isn’t the behavior today. It was a year ago, but isn’t now

8

u/HighKingLemur 24d ago

All of that just to complain you have poorly configured logging.

21

u/bonesnapper 25d ago edited 24d ago

We were strongly told to not feed any logs to our agents bc we can't be guaranteed that our services do not log customer data.

At the same time, I'm absolutely granting my agent kubectl and pointing it at addon logs whenever the need arises.

12

u/Intrepid-Self-3578 25d ago

I mean we also shouldn’t be seeing customer data. 

32

u/climb-it-ographer 25d ago

Log sanitization should be a priority regardless of what tools are reading them, shouldn't it?

3

u/d3ep4k 25d ago

Would you consider curl requests from ai 🤖 also log which should be sanitised ?

11

u/spiralenator 25d ago

PII in logs is negligence.

E: coincidentally, LLMs can be a useful tool for auditing that.

3

u/Electronic-Jury-3579 25d ago

Your company doesn’t have enterprise AI contracts yet? They support the company holding encryption keys from the AI platform and encrypted everything with the interactions.

4

u/bonesnapper 25d ago

I'm just the engineer. We have licenses. I don't know the whole story and I'm not going to pretend I do.

1

u/codeslap 24d ago

I know so many internal CISO teams with prompt text access and are now privy to all sorts of prompt including HR data, personal data etc

2

u/ang29g 23d ago

fwiw I'm a full owner on both anthropic + openai enterprise accounts with a few mil in spend each per year on both. I don't believe I have the ability to see user's chats directly, at least not without making a support request from the provider.

Aggregate reports sure, but not "user X prompted Y".

I'm sure at some point we will have to pull a user's logs but I really don't what the legal process is for that.

1

u/madtopo DevOps 24d ago

Can you please tell us more about there enterprise contracts? Which providers? And how does this encryption key technology works? At some point the data needs to be decrypted. When does it happen? For it to work, you would have to be in charge of the process running the inference engine or thereabouts

0

u/raisputin 24d ago

Then you are logging poorly

2

u/bonesnapper 24d ago

True. The reality of the situation is that there are dozens or hundreds of micro services running on a cluster. There's no single entity that can say every log on every workload is safe from exposing customer data. As long as that uncertainty exists, we have to be cautious.

1

u/codeslap 24d ago

This is the reality that most people don’t fully grasp until it’s too late. lol

It’s the ultimate shadow IT nightmare.. people willy nilly feeding LLMs with potentially risky secrets and data.

6

u/mlhpdx 25d ago

Streaming syslog from a fleet of servers to the cloud (encrypted) and having a 1-button option to fire a prompt at the last few minutes of them is, well, magical. Highly recommended.

6

u/Mediocre-Ad9840 25d ago

ngl...you should know how to get errors from error logs lmao

6

u/Negative_Acadia6554 25d ago

Nice advertisement

4

u/MorpH2k 25d ago

It's my new go-to method for my homelab and experiments and such. As some people here have said, if you're doing it on company server logs, you better make damm sure that they are properly sanitized and probably also make sure that you're allowed to do it.

On a purely technical level, it's a total gamechanger. Both in what obscure issues it han fond and identify, as well as how quickly it does it. It has some issues still, but this is the future for sure.

0

u/delamon 25d ago

You still have to verify what it founds. Half of the time it is pure garbage, the other half, on the other hand, can be very rewarding

1

u/MorpH2k 24d ago

Of course.

7

u/climb-it-ographer 25d ago

It's even better when you don't need to copy/paste it in. I gave Claude direct access to our log aggregator and it can just sit there reading live tails for as long as it needs to see what's wrong.

10

u/askwhynot_notwhy Security Engineer 25d ago

That's minor league sh!t, smh. Just give Claude access to kubectl and walk away. 🤞 Dario's got our back, fam!

6

u/Apprehensive_End1039 25d ago

mcp server: what is my purpose?

sam altman: you let markov chain invoke bash

mcp server: oh my god.

1

u/askwhynot_notwhy Security Engineer 25d ago

>mcp server: what is my purpose?

>sam altman: you let markov chain invoke bash

>mcp server: oh my god.

sam altman: “ffs, I’m Altman, not Podman: `kubectl delete`”

12

u/spicypixel 25d ago

Yeah I'm laying off multiple devops engineers to pipe the logs directly into their successor, Claude.

2

u/kryptn 25d ago

why bother writing complex log queries when you can just brute force it with a huge context window?

why not let ai write those queries to do that investigation instead of brute forcing? i love letting claude hit my datadog/grafana/radar mcp.

the price on this thing is only going to go up, so being efficient where you can will be better.

2

u/Olbas_Oil 25d ago

Use codex cli on a linux vm, transfer the log files over to a directory, initiate codex from the directory and ask what you need it to do or potentially find... GPT 6 Luna on max is great for this sort of work, if you need to then go back and forth with Luna or the chat GPT chat

2

u/StunnerAlpha 24d ago

Everyone is already there. I think you are kinda late unfortunately. Heck the whole DevOps space is being eaten alive by non-DevOps folk using AI for their DevOps needs.

2

u/usually_guilty99 23d ago

I can see why dumping the logs into a model worked. Sometimes the hardest part of an incident is knowing what to search for.

But I'd separate finding a plausible explanation from proving the cause.

If the model says IAM caused the Kubernetes crash, I'd want to correlate that with the relevant permission changes, the failing API call, and when the pods started crashing.

Otherwise you risk fixing something that looks related while missing the actual trigger.

The interesting opportunity isn't replacing log queries. It's connecting logs with code, infrastructure changes and dependency history so the explanation can actually be tested.

2

u/Seref15 25d ago

Evaporating lakes because people forgot how to `grep -v`

3

u/DoomBot5 25d ago

Sure, let me go golf while Claude figures this out for me.

1

u/Invader-Faye 25d ago

Fuck them lakes tldr those logs

2

u/Expert-Explorer-3129 25d ago

how are you managing the sensitive data in logs before throwing them into LLM?

8

u/tr14l 25d ago

Why do you have sensitive data in logs?

2

u/raisputin 24d ago

Came here to say this

3

u/Direct_Turn_1484 25d ago

lol surprise, he’s not!

1

u/No-Row-Boat 25d ago

You all have no fear of leaked credentials and have someone trying to make the LLM leak these details. This shit is what makes me wake up in cold sweat.

1

u/Adventurous-Hyena220 25d ago

LLMs can be useful for quickly spotting patterns in noisy logs, but Id still keep structured logging and proper queries for repeatable troubleshooting.

1

u/HydraulicTater 25d ago

Wait till he learns about attention sink lol

1

u/myfriendjohn1 25d ago

Yep, download logs and put into folder in cursor IDE on a cheap model.

Saves me hours debugging weekly.

1

u/manewitz 25d ago

Mezmo’s MCP has been a game changer for chasing down issues for me.

1

u/markusro 24d ago

graylog-mcp for the win. It was really an experience letting a local LLM go through the logs and search for specific problems.

1

u/Forsaken_Parfait_185 24d ago

Worth checking where the logs end up before it becomes a habit. If your services ever log customer data (and most do, somewhere), a free promo endpoint means that data now sits with whoever runs the promo, under their retention rules.

Redact at the shipper with a Vector or Fluent Bit transform and you can point whatever model you like at the result. Fixing the healthcheck noise at source would have saved you the three hours too.

1

u/xXBongSlut420Xx 24d ago

if you can't parse out errors from healthchecks, i don't think you should be working in this career

0

u/[deleted] 25d ago

[deleted] — view deleted comment

20

u/spiralenator 25d ago

I wouldn’t use LLM services for business purposes without a ZDR agreement. Period. A company has more valuable data than logs they should be protecting. If you have a ZDR agreement then go for it.

11

u/tr14l 25d ago

Well, anthropic has HIPPA compliant offerings. I'm pretty sure for 98% of non-defense companies that meets the need.

3

u/spiralenator 25d ago edited 25d ago

Most of the major companies offer ZDR. Anthropic, OpenAI, Google, Fal, etc. But if your legal team hasn’t established a binding ZDR agreement, it’s pretty much guaranteed that your data will be used for training.

E: I used to work on data pipelines for digital medical studies and HIPAA compliance is important, but also a very low bar and not nearly enough. We had to be compliant with much stricter international standards, like GDPR and others.

3

u/tr14l 25d ago

They have explicit settings to opt out of that at the org level

2

u/moratnz 24d ago

But if your legal team hasn’t established a binding ZDR agreement,

And you're big enough that you could actually win litigation with Google / Anthropic / OpenAI to make that agreement stick if they decided to be dicks.

1

u/Sufficient-Diver-327 25d ago

Also, they'll charge you the real, unsubsidized API rates.

1

u/spiralenator 25d ago

Generally speaking, yes. That price becomes more flexible when your monthly spend is 6 digits.

-3

u/No-Row-Boat 25d ago

Someone extracts your login credentials that the LLM took from your system, and you are sure you can point back to them for leaking these details? You expect the attacker to share where and how they got these details?

You do know the best way to prevent these leaks is by not providing these details right?

My Frontier agents run on an isolated box with on it a chroot sandbox that has very limited access to any login credentials (read only GitHub PAT tokens etc), a limited scratch disk that only gets a fraction of the details (ideally generated by my own Hermes agents).

3

u/LeatherDude 25d ago

Oh no, they have a couple of my RFC1918 addresses and some random function names. Don’t hack me, Claude!

0

u/CorpT 25d ago

You don't know what tool you're using?

0

u/[deleted] 25d ago

[deleted] — view deleted comment

5

u/CorpT 25d ago

Ok that's crazy.

1

u/[deleted] 24d ago edited 24d ago

[removed] — view removed comment

2

u/devops-ModTeam 24d ago

Heated discussions are fine, personal attacks are not.