Summary
- Petra Security uses ClickHouse Cloud to detect M365 account compromises in seconds, protecting millions of identities across tens of thousands of businesses.
- Async inserts absorb millions of fragmented log events per minute, while materialized views compute thousands of point-in-time detection signals at insert time.
- Testing model improvements against hundreds of millions of historical events lets Petra stay ahead of new attacker toolkits.
Catching a hacked email account used to be largely a question of geography. If a user logged in from New York on Monday and Moscow on Tuesday, something was wrong. Detection tools watched login event sequences, flagged the suspicious ones, and did a decent job of it.
That era is gone. Today’s attackers can perfectly spoof a user’s location, right down to the exact ISP they use. If a target signs in from, say, Comcast in Brooklyn, an attacker can get their own Comcast IP in Brooklyn. Based on login metadata alone, the two look identical.
The rise of LLMs is only making the problem worse. As personalized phishing becomes cheaper and endlessly scalable, attackers are increasingly using it for business email compromise (BEC), hacking inboxes and then redirecting payments or issuing fraudulent invoices. According to the FBI’s latest Internet Crime Report, BEC was the second-costliest category of cybercrime in 2025, accounting for more than $3 billion in reported losses.
Petra Security was founded to close that gap. The company provides AI-driven identity threat detection and response (ITDR) for Microsoft 365, protecting millions of identities across tens of thousands of businesses. Rather than asking where a login came from, Petra’s specialized ML models watch everything that happens after it—the messages a user opens, the files they read, the way they move through an account—looking for patterns that suggest whoever is in there doesn’t belong. As co-founder and CTO Adithya Vellal puts it, “An attacker can hide their location perfectly, but they can’t hide their intent.”
We caught up with both Adithya and Krish Sharma, VP of Engineering, to learn about the technical challenge Petra is solving, why ClickHouse Cloud is a perfect fit, and how they’re helping businesses catch more real attacks, faster, without burying teams in false alarms.
Too much, too fast, too scattered
Detecting intent starts with ingesting a massive amount of data. “It’s no longer sufficient to just look at login activity,” Krish says. “To be the best in class on coverage, we have to ingest everything else… Exchange activity, SharePoint activity, what the user is doing in Teams.”
By Adithya’s estimates, login events account for just 1% of the log data M365 produces. The other 99% is user activity, which is full of natural language: subject lines, file names, the substance of what people are working on. “You’re processing all of it and then coming up with a clear judgment on whether something’s an attack or not,” he says. “That involves taking a ton of signals and cross-correlating them across all of these event streams in real time.”
In cybersecurity, he adds, that real-time response is everything: “As soon as somebody compromises an email account, within seconds they’re reading sensitive data, and within minutes they’re sending out emails from that account and causing reputational harm or financial loss. So it’s absolutely necessary to be able to lock down these accounts in seconds.”
Multi-tenancy means that data is also heavily fragmented. As Krish puts it, “Because we’re protecting tens of thousands of businesses, and because it’s millions of users, we have to deal with the problem of this data coming in indexed by company and by user.” Instead of large sequential batches, Petra receives a continuous scatter of tiny writes fragmented across every tenant and every identity it protects, at a rate of millions of logs per minute.
For row-oriented databases, Petra’s combination of volume, urgency, and fragmentation was too much to handle. The team prototyped on Postgres, as most do, and moved on quickly. “We’re dealing with quite a bit of tabular data, so we really want to deal with columnar databases,” Krish says. “We want super efficient retrieval, but we also want to be able to insert data extremely quickly. And so that’s where we landed on ClickHouse.”
Why ClickHouse was the right fit
ClickHouse’s asynchronous inserts let Petra write events as they arrive and leave the batching to the database. “We no longer have to maintain a buffer internally and figure out how to flush it in an efficient way so that we’re not spiking CPU,” Krish says. “We want to aggregate all of these events happening across millions of identities per second and get that data indexed as fast as possible, all in service of that ultimate goal of having laser-fast detection.”
As logs land, materialized views compute and correlate thousands of statistical signals across the login, Exchange, and SharePoint streams. “That’s been a total game-changer,” Adithya says. “Materialized views are purpose-built for computing those signals really, really fast, so that we can do AI inference on them. With ClickHouse, the most important thing we get is speed.”
Timing, Krish notes, is another advantage. Petra’s forensics-first detection models leverage AI agents that read those precomputed signals rather than the raw logs.
“AI agents are incredible at deducing information, but there’s quite a bit of data we want to compute at point in time. With materialized views, we get that instantaneously at insert time.” — Krish Sharma, VP of Engineering, Petra Security
The models can look at a very salient piece of data to determine whether it’s malicious or benign. Capturing that point-in-time data that is literally only existing at that second is what allows Petra to catch attacks that others miss.
For a small team like Petra’s, deciding between ClickHouse Cloud and self-hosting was, as Krish puts it, a no-brainer. “At the end of the day, we’re a detection company,” he says. “We’re not super interested in managing the entirety of a Kubernetes cluster. ClickHouse Cloud gives us both the security we need as a cybersecurity company, but also the scalability and the speed we need in order to provide best-in-class detection.”
The managed service cleared two other requirements: the compliance attestations Petra has to meet as a security vendor, and compute-compute separation, which lets the team run heavy backfills on their own compute. “Especially as we add new, larger partners, we’re indexing the past six months of data for them,” Krish says. “That should not and does not impact our ability to do detection in any shape or form.” Over the last few months, Petra has added over 2 million identities. “It’s basically gone without a hitch on the ClickHouse side,” he adds.
Staying ahead of attackers
Petra is what’s known in cybersecurity as a channel-only company, selling to businesses of all sizes through managed service providers (MSPs), which handle IT and security for their own clients, and through resellers. A single MSP might cover dozens or hundreds of businesses, including SMBs that can’t staff a security team of their own. “One of the key value propositions of Petra is we make it really easy for our partners to sell the outcome of better Microsoft security and threat detection,” Adithya says.
When a partner brings in a prospective client, Petra indexes six months of their M365 history and reconstructs what it finds. They call it Petra Scan. “You pull out all the past compromises that happened with full forensic detail of every single thing the attacker did, in a very clear timeline,” Adithya says. “The attacker got in at this time, here are the emails they exfiltrated, here are the SharePoint files they read, here are the emails they sent out.”
One partner ran a Scan for a public pharmaceutical company that had recently suffered a compromise involving one of its executives. Expensive incident response engagements had failed to produce a clear account of what the attacker did. “They onboarded into Petra, and 24 hours later they had a full report of everything that had happened,” Adithya says. “That level of detail convinced the client that, yeah, this is the right thing for us.”
Petra is just as careful about what it doesn’t flag. Every signal it computes is preserved, so every improvement to its detection can be proven out before it ever reaches a customer. “When we make an update to our models, we’re able to test it across the hundreds of millions of events that we’ve captured, and make sure our coverage is super high and we’re not going to see a deluge of alerts impact customers’ productivity,” Krish says. “A huge reason people buy Petra is because our false positive rate is best in class.”
Fast testing also means fast shipping. When a new attacker toolkit appears, Petra can validate improvements against its full history and push them out the same day. “Within hours, we’re able to keep our customers protected from the latest attack we’ve detected,” Krish says. “Attackers only have to be right once. We have to get it right every single time.”
That accumulated corpus now feeds AI threat hunting agents that query ClickHouse directly through the ClickHouse MCP server, discovering schemas and surfacing emergent attack techniques without being told what to look for.
“For us to stay ahead of attackers, iteration speed is paramount. Our agents run workflows autonomously overnight to test the hypotheses we have every evening, and for us to show up with the results ready to go is entirely because we are built on top of ClickHouse.” — Adithya Vellal, co-founder and CTO, Petra Security
From detection to prevention
One of Petra’s newest products is the Activity Viewer, which Krish calls a “happy accident of sorts.” The team had built an internal interface for querying M365 activity; when they exposed it to customers, partners began dropping a separate Microsoft data-indexing product they had been paying for. “They’re able to look at login activity, Exchange activity, SharePoint, Teams in a matter of seconds, versus their existing interfaces, which are async batch queries that run on a remote cluster and take minutes, if not hours,” he says.
Looking ahead, Petra has big plans for its growing corpus of M365 data. “We’re really the only ones who have this dataset across all these log streams of attacker and user intent,” Adithya says. “That enables us to continue investing and being best in class at attack detection, and there are a lot of other use cases we can support with this as well.”
The long-term vision is stopping compromises before they start. “When we see a compromise on one account, we want to make sure the other million-plus identities don’t even have to deal with that compromise,” Krish says. “Can we identify a combination of signals we could suggest as a policy in M365 that would allow that login activity to be blocked altogether, rather than catching it after the fact? We want to help our partners reduce business disruption and really focus on what they bought M365 for in the first place, which is their productivity.”
Adithya sums up Petra’s value proposition simply: “We catch attacks that other people miss, we catch them faster than everybody else, and we don’t alert on things that aren’t attacks.” It all traces back to a decision the team made early about which database to build on. “When you’re a fast-scaling company, nailing these decisions that seem simple is really important,” he says. “We nailed it with ClickHouse.”
Get started today
Interested in seeing how ClickHouse works on your data? Get started with ClickHouse Cloud in minutes and receive $300 in free credits.
Sign up


