Twitter (X) Data in Splunk: Send Tweets to the HTTP Event Collector

By TwitterAPI.io Team•13 min read
Diagram: Twitter (X) keyword search via advanced_search, shaped into HEC events, sent to the Splunk HTTP Event Collector, and charted with timechart span=1h count.
From an X keyword to a Splunk alert, sized with 1,898 real tweets collected in 2026.
TL;DR
  • No maintained app: Splunkbase's App for Twitter Data is archived (3.0.1, 2015) and its GitHub repo is read-only; build a poller that feeds the HTTP Event Collector instead.
  • Pipeline: /twitter/tweet/advanced_search with since_time: → dedupe by id → trim → POST to /services/collector/event with Authorization: Splunk <token>.
  • Real volume: "ransomware" in English produced 614 events on the latest full day in our sample, from 6 to 66 per hour.
  • Trim before you send: median HEC event 4,776 bytes with the full tweet object vs 769 bytes trimmed (81% less on average); 199 full objects passed the 10,000-byte TRUNCATE default.
  • Cost: polling every 5 minutes cost about $3.06 per 30 days for this keyword; every 60 seconds about $7.29, because 69.9% of minutes were empty.
  • SPL: timechart span=1h count for volume, streamstats for a moving baseline, spath + mvexpand for hashtag threat-intel rollups.

This page is about one destination: Splunk. Our Twitter monitoring via API guide covers how to watch accounts and keywords in general and where alerts can go; here we take that feed and land it in a Splunk index through the HTTP Event Collector, with the field design, SPL searches and ingest sizing a security or brand team needs.

Security operations teams use X as an early-warning source: ransomware leak-site announcements, CVE chatter, outage reports and phishing campaigns often surface in posts before they reach a vendor feed. Splunk is where many of those teams already alert, so the useful question is not "can Splunk read Twitter" but "what is the smallest reliable pipe, and how much data does it push".

We answered the second half with real data: 1,898 English tweets matching "ransomware", wrapped as HEC events exactly as the Splunk docs describe, measured for events per hour, bytes per event and API cost. We could not run a Splunk instance for this page, so every Splunk step below is per the Splunk docs, and the hourly counts were computed in Python with the same one-hour bucketing timechart span=1h performs.

Events one security keyword sends to Splunk in a day

614 tweets for "ransomware" (English, no retweets) on the latest full day, peaking at 66 in one hour; 0.65 MB as trimmed HEC events vs 3.46 MB with full tweet objects (1,898 tweets, collected in 2026).

01 — Section

What happened to the Splunk Twitter app

Searches for "splunk twitter app" still lead to Splunkbase app 1162, the App for Twitter Data. Its Splunkbase page reads "This app is archived", lists version 3.0.1 released January 9, 2015, and describes it as a scripted input that "automatically extracts tweets from Twitter's 1% sample stream". The source repository, github.com/splunk/splunk-app-twitter, is marked as archived by its owner on GitHub and read-only; its README says it was tested on Splunk 6.0 and 6.1 and links the Twitter API v1.1 sample stream documentation.

Two things make it a dead end. First, it was built for a random 1% sample, not for the keywords or accounts a security team cares about. Second, it depends on a Twitter API generation and credential model that predates the current X developer platform, whose pricing page (docs.x.com/x-api/getting-started/pricing) now bills per resource read. Other Twitter listings on Splunkbase (an alert action that posts tweets, a SOAR connector, community add-ons) are also archived or unmaintained.

The replacement is not another app. Splunk ships a general-purpose HTTP ingestion path, the HTTP Event Collector, and any script that can make an HTTPS POST can feed it. That keeps the X side (which query, which accounts, how often) in code you control and the Splunk side (index, sourcetype, searches, alerts) in Splunk.

02 — Section

Architecture: poll X, shape the event, POST to HEC

Collect. Call GET /twitter/tweet/advanced_search with queryType=Latest and a query such as ransomware -filter:retweets lang:en since_time:<unix>. Each page returns up to 20 tweets in a top-level tweets[] array with has_next_page and next_cursor; follow the cursor until has_next_page is false. No X account or X developer app is needed for reads.

Shape. Keep a set of tweet ids you have already sent and drop repeats (a small overlap in since_time is safer than a gap). Map createdAt ("Thu Oct 16 12:34:56 +0000 2026") to epoch seconds for the HEC time key so Splunk indexes the tweet at the moment it was posted, not the moment you fetched it. Trim the tweet object to the fields you will search on.

Send. POST to /services/collector/event with Authorization: Splunk <token>. Per the Splunk docs you can batch several events in one request, either concatenated JSON objects or a JSON array, which keeps HTTP overhead low when a busy hour delivers dozens of tweets at once.

Search and alert. A dedicated index (we use social) and sourcetype (twitter:tweet) let you chart volume with timechart, build a moving baseline with streamstats, and save the spike search as a scheduled alert.

If you prefer push over pull, TwitterAPI.io filter rules (POST /oapi/tweet_filter/add_rule, then POST /oapi/tweet_filter/update_rule with is_effect=1 to activate) push matching tweets to your webhook or WebSocket; your receiver then forwards them to HEC the same way. The payload and receiver details are in our Twitter webhooks guide. Polling is simpler to run next to Splunk and is what we sized below.

03 — Section

Set up the HTTP Event Collector (per the Splunk docs)

Splunk Enterprise. The Splunk Enterprise docs ("Set up and use HTTP Event Collector in Splunk Web") say to enable HEC through the Global Settings dialog: go to Settings > Data Inputs > HTTP Event Collector, click Global Settings, set All Tokens to Enabled, optionally tick Enable SSL so HEC uses HTTPS, optionally change the HTTP Port Number, and save. The port "is 8088 by default". Confirm that no firewall blocks it on the client or the Splunk host.

Create a token. Settings > Add Data > monitor > HTTP Event Collector, enter a name, click Next, confirm the source type and index (create the social index first, or pick an existing one), Review, Submit, and copy the token value. Indexer acknowledgment is an optional checkbox on Enterprise; if you enable it, requests also need a channel identifier.

Splunk Cloud Platform. The Splunk Cloud docs say standard HEC "is enabled by default on all Splunk Cloud Platform deployments". The URL shape differs: https://http-inputs-<host>.splunkcloud.com:443/services/collector/event on AWS-hosted paid stacks, port 8088 on free trials, and http-inputs.<host>.splunkcloud.com (a dot, not a hyphen) on GCP or Azure. Leaving off the http-inputs prefix means the data never reaches HEC. On Cloud the target index must already exist.

Test before you code. Send one hand-written event with curl and look for {"text":"Success","code":0}; then search index=social sourcetype=twitter:tweet over the last 15 minutes. Use -k only against a test instance with a self-signed certificate.

bash
curl -k "https://splunk.example.com:8088/services/collector/event" \
  -H "Authorization: Splunk 12345678-1234-1234-1234-1234567890AB" \
  -d '{"sourcetype":"twitter:tweet","index":"social","event":{"text":"hec test","query":"ransomware"}}'
# expected: {"text":"Success","code":0}
04 — Section

Design the event: trim the tweet, set time and sourcetype

The HEC event endpoint takes an envelope with optional metadata keys and one event payload. Per the Splunk docs: time is epoch seconds with optional milliseconds (<sec>.<ms>), host, source and sourcetype label the data, index must be one the token is allowed to write, and any key you omit falls back to the token's defaults. The event value can be a string or a nested JSON object.

We measured both choices for the payload. Full object: pass the tweet exactly as advanced_search returns it, author profile, entities, media and quoted tweet included. Trimmed: 16 fields (id, url, created_at, text, lang, author handle, author follower count, reply flag, five engagement counts, hashtags, expanded links, the query that matched).

HEC event shapemedian bytesp95 bytesmax bytesmean bytes
Full tweet object4,77612,46727,6035,639
Trimmed, 16 fields7692,04322,1371,064

Trimming cut the average event by 81%. It also matters for a quieter reason: Splunk's props.conf reference lists TRUNCATE with a default of 10,000 bytes ("the default maximum line length"), and 199 of the 1,898 full tweet objects in our sample were larger than that. Long-form posts and tweets that quote other tweets push the size up; the largest trimmed event was still 22,137 bytes because the text itself was long. Either trim, or raise TRUNCATE for the sourcetype, or both.

Set KV_MODE = json on the twitter:tweet sourcetype so fields such as author, likes and hashtags{} are extracted at search time. The props.conf reference warns not to also set INDEXED_EXTRACTIONS = JSON on the same sourcetype, which would extract every field twice.

ini
# props.conf on the indexer / search head (or set in Splunk Web)
[twitter:tweet]
KV_MODE = json
TRUNCATE = 0          # or a number larger than your largest event
SHOULD_LINEMERGE = false
Bar chart of HEC event size: trimmed median 769 bytes, trimmed p95 2,043, full tweet median 4,776, full tweet p95 12,467, with the 10,000-byte TRUNCATE default marked.
Bytes per HEC event for 1,898 real tweets, collected in 2026: trimming cuts 81% on average.
05 — Section

How much data one security keyword sends to Splunk

This is the number every Splunk admin asks first. For English tweets matching "ransomware" with retweets excluded, the latest full UTC day in our sample held 614 events. Hour by hour it ranged from 6 to 66: the peak hour was 11.0x the quietest, so a static alert threshold set at the overnight level would fire every afternoon.

Measure (latest full UTC day)value
Events (tweets)614
Peak hour / quietest hour66 / 6
HEC ingest, full tweet objects3.46 MB
HEC ingest, trimmed events0.65 MB
30 days at that rate, full / trimmed103.9 MB / 19.6 MB
API cost to read those tweets$0.09 a day, $2.76 per 30 days

Across all 115 complete hours in the sample, the median was 12 events per hour, the 90th percentile 32 and the maximum 66. One keyword is small for Splunk. The volume grows with the query: a list of 20 ransomware group names, product names or CVE ids multiplies it, and a brand name with consumer reach can be orders of magnitude larger. Size with your own query by running it for a day before you commit to a license tier.

Content matters for parsing too: 45.8% of the tweets carried at least one link, 45.7% at least one hashtag, 41.0% had media attached, 13.5% were replies and 4.3% quoted another tweet. Links are often the payload a threat analyst wants (a leak-site screenshot, an advisory), which is why the trimmed event keeps expanded URLs.

Bar chart of hourly tweet counts for ransomware on one UTC day, 614 total, peaking at 66 events in one hour and dropping to 6.
The result timechart span=1h count would show for "ransomware" on the latest full day: 614 events. Collected in 2026; bucketed in Python.
06 — Section

SPL searches: volume, spikes and threat-intel rollups

Volume. timechart bins events by _time; the Splunk search reference notes that without span or bins it uses bins=100, so pass span=1h explicitly, and use span=1d (not span=24h) when you want day boundaries. Because the poller sets time from createdAt, _time is the tweet's post time.

Spikes. A moving baseline handles the 11.0x daily swing better than a fixed number. The search below compares each hour to the previous 24 and keeps hours that are at least double the baseline and more than three standard deviations above it. Save it as an alert on a one-hour schedule. Tune the thresholds on a week of your own data before routing it to on-call.

Threat-intel rollups. Hashtags and group names cluster fast when a new leak or campaign appears. The third search expands the hashtags{} array, counts mentions and distinct authors per tag, and ignores tags pushed by fewer than five accounts, which filters out a single account repeating itself.

In our sample, the leading hashtags were #ransomware (384), #cybersecurity (293), #databreach (99), #infosec (99) and #threatintel (97); the named group #qilin appeared 56 times. Several of the top 10 were obscure tags used heavily by a small set of accounts, which is exactly what the distinct-author filter is for.

spl
index=social sourcetype=twitter:tweet
| timechart span=1h count

index=social sourcetype=twitter:tweet earliest=-7d@h latest=@h
| timechart span=1h count AS tweets
| streamstats window=24 current=f avg(tweets) AS baseline stdev(tweets) AS sd
| eval z=round((tweets-baseline)/sd, 1)
| where tweets > 2*baseline AND z > 3

index=social sourcetype=twitter:tweet
| spath path=hashtags{} output=tag
| mvexpand tag
| eval tag=lower(tag)
| stats count AS mentions dc(author) AS authors BY tag
| where authors >= 5
| sort - mentions
| head 20
07 — Section

Poll interval, batching and what it costs

TwitterAPI.io bills tweet reads at 15 credits per tweet returned, $0.15 per 1,000 tweets, with a minimum of 15 credits ($0.00015) per request, so a poll that finds nothing still costs $0.00015. We replayed the latest full day against two poll intervals to see how many polls come back empty and how large a batch HEC receives.

Poll intervalpolls a dayempty pollslargest batchest. cost per 30 days
60 seconds1,44069.9%13 tweets$7.29
5 minutes28822.9%15 tweets$3.06

At 60 seconds, 69.9% of polls return nothing and those empty calls are the larger part of the bill. At 5 minutes the cost falls to about $3.06 per 30 days and the data lands at worst five minutes late, which suits hourly timechart alerts. Every batch in our replay fit one 20-tweet page; a busier query will need the cursor loop in the code below.

For comparison, the official X API rate card at docs.x.com/x-api/getting-started/pricing lists $0.005 per post read; the same 30 days of tweets (18,420 posts) would be $92.10 there against $2.76 at $0.15 per 1,000, about 33x apart per 1,000 tweets. X's pay-per-usage plans are capped at 3 million post reads per monthly billing cycle, with Enterprise above that. Rate limits on our side are 0.2 requests per second before the first payment and 20 once paid; see pricing for plans and free starter credits (no card, one per person or network, expiring after 31 days).

08 — Section

Run it: scheduling, retries and running next to Splunk

The full script is in the code block below this article. Run it as a systemd service or a container next to your heavy forwarder, or as a scheduled function: the state file (last since_time and recent ids) is the only thing that must persist between runs. Our AWS Lambda guide shows the same polling pattern on a schedule with state kept outside the function.

Retries. If HEC is down, do not advance since_time: the script only saves state after a successful send, so the next cycle re-reads the window and the id set prevents duplicates. If the X side errors, the loop logs it and tries again on the next fixed interval.

Backfill. To seed an index with history, run the same search with since_time: and until_time: set to a past window and send the results once; timechart will place them correctly because each event carries its own time.

Fan-out. If several teams consume the same tweets (Splunk for the SOC, a data lake for analysts), write once to a stream and let each sink read it; our Kafka pipeline guide covers that layout, with Splunk as one consumer.

Never put the HEC token in code or logs. Keep it in the environment or a secrets manager, scope the token to the social index only, and rotate it like any other credential.

09 — Section

How we collected this

Question. If every tweet matching one security keyword were sent to Splunk through HEC, how many events per hour and per day would arrive, how large would each event be, and what would the reads cost?

Query. ransomware -filter:retweets lang:en on /twitter/tweet/advanced_search with queryType=Latest, following next_cursor newest first. 96 requests returned 1,918 tweets (1,898 unique) for a study cost of $0.29. Collected in 2026; the sample spans about 116 hours.

Method. Each tweet was wrapped in an HEC envelope (time, host, source, sourcetype, index, event) and serialized as compact UTF-8 JSON to measure bytes, once with the full tweet object and once trimmed to 16 fields. Hourly counts were computed in Python with one-hour UTC buckets, the same bucketing as timechart span=1h count. Poll costs replay the latest full day at 60-second and 5-minute windows using the published per-tweet price and per-request minimum.

What the sample cannot show. The search returned fewer tweets for older days: the three complete UTC days held 190, 325 and 614 tweets, oldest first. We cannot tell whether that is real growth in chatter or a search result set that thins further back in time, so the daily figures use the latest full day and should be read as a floor for live polling. One keyword in one language is not every security feed. We did not run Splunk, so indexing overhead, license metering and search performance are not measured; Splunk behavior is described per its docs.

Privacy. Aggregates only. Raw search pages stayed on a temporary disk and were not kept with the study; the published sample holds de-identified rows (hour index, byte sizes, text length, flags) with no tweet ids, URLs, text, handles or author ids.

python
"""twitter_to_splunk.py - poll X (Twitter) for a keyword and send each new tweet
to Splunk through the HTTP Event Collector (HEC).

Requirements: pip install requests
Env: TWITTERAPI_KEY, SPLUNK_HEC_URL (e.g. https://splunk.example.com:8088),
     SPLUNK_HEC_TOKEN, optional SPLUNK_INDEX (default "social").
"""
import json
import os
import time
from datetime import datetime

import requests

BASE = "https://api.twitterapi.io"
API_KEY = os.environ["TWITTERAPI_KEY"]
HEC_URL = os.environ["SPLUNK_HEC_URL"].rstrip("/") + "/services/collector/event"
HEC_TOKEN = os.environ["SPLUNK_HEC_TOKEN"]
INDEX = os.environ.get("SPLUNK_INDEX", "social")
QUERY = "ransomware -filter:retweets lang:en"
POLL_SECONDS = 300          # fixed pacing; 60 also works, see the cost table
STATE_FILE = "splunk_state.json"


def load_state():
    if os.path.exists(STATE_FILE):
        with open(STATE_FILE) as f:
            return json.load(f)
    return {"since": int(time.time()) - 3600, "seen": []}


def save_state(state):
    state["seen"] = state["seen"][-5000:]          # bounded dedupe memory
    with open(STATE_FILE, "w") as f:
        json.dump(state, f)


def fetch_new(since_unix):
    """All tweets matching QUERY created after since_unix, newest first."""
    q = f"{QUERY} since_time:{since_unix}"
    tweets, cursor = [], ""
    while True:
        params = {"query": q, "queryType": "Latest"}
        if cursor:
            params["cursor"] = cursor
        r = requests.get(f"{BASE}/twitter/tweet/advanced_search",
                         headers={"X-API-Key": API_KEY}, params=params, timeout=30)
        r.raise_for_status()
        body = r.json()
        tweets.extend(body.get("tweets", []))
        if not body.get("has_next_page") or not body.get("next_cursor"):
            return tweets
        cursor = body["next_cursor"]


def to_epoch(created_at):
    # "Thu Oct 16 12:34:56 +0000 2026"
    return datetime.strptime(created_at, "%a %b %d %H:%M:%S %z %Y").timestamp()


def to_hec(t):
    """One HEC event: Splunk metadata outside, a trimmed tweet inside."""
    author = t.get("author") or {}
    ent = t.get("entities") or {}
    return {
        "time": to_epoch(t["createdAt"]),
        "host": "twitter-poller",
        "source": "twitterapi.io:advanced_search",
        "sourcetype": "twitter:tweet",
        "index": INDEX,
        "event": {
            "id": t["id"],
            "url": t.get("url"),
            "created_at": t["createdAt"],
            "text": t.get("text"),
            "lang": t.get("lang"),
            "author": author.get("userName"),
            "author_followers": author.get("followers"),
            "is_reply": t.get("isReply"),
            "likes": t.get("likeCount"),
            "retweets": t.get("retweetCount"),
            "replies": t.get("replyCount"),
            "quotes": t.get("quoteCount"),
            "views": t.get("viewCount"),
            "hashtags": [h.get("text") for h in ent.get("hashtags") or []],
            "links": [u.get("expanded_url") for u in ent.get("urls") or []],
            "query": QUERY,
        },
    }


def send_to_splunk(events):
    """Batch: HEC accepts several JSON event objects concatenated in one POST."""
    for i in range(0, len(events), 100):
        chunk = events[i:i + 100]
        body = "".join(json.dumps(e, separators=(",", ":")) for e in chunk)
        r = requests.post(HEC_URL, data=body.encode("utf-8"), timeout=30,
                          headers={"Authorization": f"Splunk {HEC_TOKEN}"})
        r.raise_for_status()                      # HEC answers {"text":"Success","code":0}


def run_once(state):
    started = int(time.time())
    seen = set(state["seen"])
    fresh = [t for t in fetch_new(state["since"]) if t["id"] not in seen]
    fresh.reverse()                               # oldest first into Splunk
    if fresh:
        send_to_splunk([to_hec(t) for t in fresh])
        state["seen"].extend(t["id"] for t in fresh)
    state["since"] = started - 120                 # small overlap; dedupe catches repeats
    save_state(state)
    print(f"sent {len(fresh)} events")


if __name__ == "__main__":
    st = load_state()
    while True:
        try:
            run_once(st)
        except requests.RequestException as exc:  # Splunk or API hiccup: retry next cycle
            print("error:", exc)
        time.sleep(POLL_SECONDS)

Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.

10 — Questions

Questions readers ask

Is there still a Twitter app for Splunk?

Not a maintained one. Splunkbase app 1162, App for Twitter Data, is marked archived; its last version is 3.0.1 from January 9, 2015, and it read Twitter's 1% sample stream. The GitHub repository is archived and read-only. Other Twitter listings on Splunkbase are archived or unmaintained too. The current approach is a small script that searches X and sends tweets to the HTTP Event Collector.

How do I send tweets to Splunk HTTP Event Collector?

Enable HEC (Settings > Data Inputs > HTTP Event Collector > Global Settings on Splunk Enterprise; it is on by default on Splunk Cloud), create a token tied to an index, then POST JSON to /services/collector/event with the header Authorization: Splunk <token>. Put the tweet under event, its post time in epoch seconds under time, and a sourcetype such as twitter:tweet. You can batch several events in one request.

Should I use the event endpoint or the raw endpoint?

Use /services/collector/event for tweets. It takes structured JSON with per-event time, sourcetype and index, and it is the only endpoint that accepts the fields key for index-time fields. The raw endpoint /services/collector/raw takes unstructured text and requires an X-Splunk-Request-Channel header.

How large is a tweet as a Splunk event?

In our sample of 1,898 tweets the full tweet object averaged 5,639 bytes as an HEC event (median 4,776, max 27,603), and 199 were above the 10,000-byte TRUNCATE default. Trimmed to 16 fields the average was 1,064 bytes, 81% smaller.

How many tweets a day will a keyword add to my Splunk index?

It depends entirely on the query. English tweets matching "ransomware", retweets excluded, were 614 on the latest full day of our sample, 0.65 MB as trimmed events. Brand names and broad terms can be far larger; run your query for a day and count before sizing.

Do I need an X developer account to get Twitter data into Splunk?

Not with TwitterAPI.io: reads use an API key in the X-API-Key header and no X account. Tweets cost $0.15 per 1,000 returned, with a $0.00015 minimum per request. The official X API is also an option; its pricing page lists $0.005 per post read on pay-per-usage, capped at 3 million post reads per monthly billing cycle.

How do I alert on a spike of tweets in Splunk?

Chart volume with timechart span=1h count, then compute a moving baseline with streamstats window=24 current=f avg(count) stdev(count) and keep hours well above it. Save that search as an alert on an hourly schedule. A fixed threshold works poorly because hourly volume swings widely across the day.

Can Splunk push tweets in real time instead of polling?

Splunk HEC only receives; something has to send. You can poll every minute or few minutes, or use a TwitterAPI.io filter rule that pushes matching tweets to your webhook, and have that receiver forward each batch to HEC.

11 — Further reading

Continue

Sources & further reading
More from this series

Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.

Build it

Stop reading. Start building.

Starter credits cover real testing on real data. Google sign-in, no card, no application queue.

Get an API key

Already building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.