Skip to content

Commit 4f4048e

Browse files
committed
Create Blog “integrating-hpe-greenlake-webhooks-with-splunk”
1 parent 67f6da5 commit 4f4048e

File tree

1 file changed

+340
-0
lines changed

1 file changed

+340
-0
lines changed
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
---
2+
title: "Integrating HPE GreenLake webhooks with Splunk "
3+
date: 2025-06-24T11:34:04.977Z
4+
author: Vandewilly Silva
5+
authorimage: /img/Avatar1.svg
6+
disable: false
7+
tags:
8+
- hpe_greenlake_cloud
9+
- webhooks
10+
---
11+
# Overview
12+
13+
This guide shows you how to connect HPE GreenLake webhooks with [Splunk](https://www.splunk.com/). Splunk is a data platform that collects, indexes, and analyzes machine-generated data to provide insights for various purposes, including security monitoring, IT operations, and business analytics. When the two are connected, you will be able to see your HPE GreenLake events through Splunk for improved data monitoring and analysis.
14+
15+
# What you’ll learn
16+
17+
* How to set up Splunk to receive data from HPE GreenLake
18+
* How to handle HPE GreenLake's security requirements
19+
* How to build a helper app that makes everything work together
20+
* How to test and monitor your setup
21+
22+
# Overview of Splunk HTTP Event Collector (HEC)
23+
24+
The [HTTP Event Collector (HEC)](https://dev.splunk.com/enterprise/docs/devtools/httpeventcollector/) is a Splunk feature that lets you send data and application events to a Splunk deployment over the HTTP and Secure HTTP (HTTPS) protocols. HEC uses a token-based authentication model. You can generate a token and then configure a logging library or HTTP client with the token to send data to HEC in a specific format.
25+
26+
## Key features of HEC
27+
28+
* Token-based authentication: Each token has a unique value, which is a 128-bit number that is represented as a 32-character globally unique identifier (GUID)
29+
* Secure communication: Supports both HTTP and HTTPS protocols for data transmission
30+
* API key support: Provides secure authentication mechanisms that align perfectly with HPE GreenLake's security requirements
31+
* Flexible data formats: Accepts both JSON-formatted events and raw text data
32+
33+
# Overview of HPE GreenLake webhooks
34+
35+
[HPE GreenLake webhooks](https://developer.greenlake.hpe.com/docs/greenlake/services/event/public/webhooks/) facilitate automated, real-time communication between HPE GreenLake cloud services and an external service of your choosing. For example, a webhook could notify your IT Operation Management platform when a new audit log is created, or when subscriptions are about to expire. A getting started guide to HPE GreenLake webhooks is available [here](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/).
36+
37+
## HPE GreenLake webhook security features:
38+
39+
HPE GreenLake implements robust security measures to ensure webhook authenticity:
40+
41+
* Challenge Request Validation: After registering a webhook, a verification challenge is sent to the destination (the webhook URL). The event type is hpe.greenlake.events.v1beta1.webhooks.verification. The challenge request includes a unique, random string generated by the server that is sent in the body as a payload.
42+
* HMAC SHA-256 Signature Verification: HPE GreenLake webhooks use a verification challenge process to ensure that webhook connections are legitimate and secure. HPE GreenLake secures webhook notifications through HMAC (Hash-based Message Authentication Code) with SHA-256, a cryptographic hashing algorithm.
43+
* Shared Secret Management: The platform supports dual secret rotation for zero-downtime security updates.
44+
45+
Challenge Request Example:
46+
47+
```json
48+
{
49+
"specversion" : "1.0",
50+
"type" : "hpe.greenlake.events.v1beta1.webhooks.verification",
51+
"source" : "//global.api.greenlake.hpe.com/events",
52+
"id" : "C234-1234-1234",
53+
"time" : "2018-04-05T17:31:00Z",
54+
"datacontenttype" : "application/json",
55+
"data" : {
56+
"challengeRequest" : "<TOKEN>"
57+
}
58+
}
59+
```
60+
61+
# Challenges and solutions
62+
63+
The primary challenge in integrating HPE GreenLake webhooks with Splunk HEC lies in the webhook verification process. The destination must read the value from the challengeRequest field and create an HMAC SHA-256 hash, using the webhook secret as salt and the challengeRequest value as a string to hash. When successful, the destination responds with a JSON object with the format {"verification": "CREATED_HASH"} and a HTTP 200 OK status.
64+
65+
## A challenge
66+
67+
Splunk's HEC endpoint is designed for data ingestion and doesn't natively support the  challenge-response mechanism required by HPE GreenLake webhooks. HEC expects to receive event data directly and cannot handle the initial verification handshake.
68+
69+
## The solution
70+
71+
This is where [Splunk's custom REST endpoints](https://dev.splunk.com/enterprise/docs/devtools/customrestendpoints/) capability becomes invaluable. A custom REST endpoint is a developer-defined endpoint and associated handler that lets you build out the Splunk REST API to meet your specific needs. We can create a custom endpoint handler that:
72+
73+
1. Intercepts the initial challenge request from HPE GreenLake
74+
2. Validates the challenge using HMAC SHA-256
75+
3. Responds appropriately to complete the verification
76+
4. Forwards validated event data to HEC for ingestion
77+
78+
# Custom REST endpoints in Splunk
79+
80+
Splunk's custom REST endpoints provide powerful extensibility for scenarios exactly like ours. You use a custom endpoint to add a special feature that Splunk doesn't have built-in, like, in our case, handling the unique secret handshake from HPE GreenLake.
81+
82+
Key benefits of our integration:
83+
84+
* Flexible request handling: Can process both challenge requests and event data
85+
* Custom logic implementation: Handler code implements HPE GreenLake's specific validation requirements
86+
* Centralized management: Provides a single endpoint for webhook management
87+
88+
# Where to configure the endpoint handler: Splunk Enterprise vs Splunk Cloud
89+
90+
Splunk Enterprise is the self-hosted version that an organization deploys and manages on its own infrastructure, either on-premises (on-prem) or in a private cloud.
91+
92+
Splunk Cloud Platform is the Software as a Service (SaaS) offering, where the Splunk platform is hosted, managed, and maintained by Splunk.
93+
94+
## For Splunk Enterprise
95+
96+
You can install and configure the endpoint handler directly on your Splunk Enterprise instance by placing it in the etc/apps/ directory and following the steps in this guide. Splunk Enterprise supports custom REST endpoints out of the box.
97+
98+
For Splunk Cloud\
99+
[Splunk Cloud has extra security controls](https://docs.splunk.com/Documentation/SplunkCloud/latest/RESTTUT/RESTandCloud), so you might need to take additional steps to allow your helper to communicate with the Splunk REST API.
100+
101+
# Sample Python app for validation
102+
103+
Let's create a custom REST endpoint handler in Python to handle the HPE GreenLake webhook validation and forwards events to Splunk HEC, once validated.
104+
105+
## Directory structure
106+
107+
`splunk_hpe_webhook_app/
108+
├── bin/
109+
│   └── hpe_webhook_handler.py
110+
├── default/
111+
│   ├── restmap.conf
112+
│   └── web.conf
113+
└── metadata/
114+
└── default.meta`
115+
116+
## Python handler (bin/hpe_webhook_handler.py)
117+
118+
```python
119+
import os
120+
import sys
121+
import json
122+
import hmac
123+
import hashlib
124+
import urllib.request
125+
import urllib.parse
126+
from splunk.rest import BaseRestHandler
127+
class HPEWebhookHandler(BaseRestHandler):
128+
def __init__(self, command_line, command_arg):
129+
super(HPEWebhookHandler, self).__init__(command_line, command_arg)
130+
# Configure your HEC endpoint and token
131+
self.hec_url = "<https://your-splunk-instance:8088/services/collector/event>"
132+
self.hec_token = "YOUR_HEC_TOKEN_HERE"
133+
self.webhook_secret = "YOUR_WEBHOOK_SECRET_HERE"
134+
def handle_POST(self):
135+
"""Handle POST requests from HPE GreenLake webhooks"""
136+
try:
137+
# Parse the incoming request body
138+
request_body = json.loads(self.request['payload'])
139+
event_type = request_body.get('type', '')
140+
# Check if this is a verification challenge
141+
if event_type == 'hpe.greenlake.events.v1beta1.webhooks.verification':
142+
return self._handle_challenge(request_body)
143+
else:
144+
# Validate signature for regular events
145+
if self._validate_signature():
146+
return self._forward_to_hec(request_body)
147+
else:
148+
return self._return_error("Invalid signature", 401)
149+
except Exception as e:
150+
return self._return_error(f"Error processing request: {str(e)}", 500)
151+
def _handle_challenge(self, request_body):
152+
"""Handle HPE GreenLake webhook verification challenge"""
153+
try:
154+
# Extract challenge request token
155+
challenge_request = request_body['data']['challengeRequest']
156+
# Create HMAC SHA-256 hash
157+
hmac_hash = hmac.new(
158+
key=self.webhook_secret.encode('utf-8'),
159+
msg=challenge_request.encode('utf-8'),
160+
digestmod=hashlib.sha256
161+
)
162+
# Create verification response
163+
verification_response = {
164+
"verification": hmac_hash.hexdigest()
165+
}
166+
# Return successful verification
167+
self.response.setHeader('content-type', 'application/json')
168+
self.response.write(json.dumps(verification_response))
169+
return
170+
except Exception as e:
171+
return self._return_error(f"Challenge validation failed: {str(e)}", 400)
172+
def _validate_signature(self):
173+
"""Validate HMAC signature for regular webhook events"""
174+
try:
175+
# Get signature from headers
176+
signature_header = self.request.get('headers', {}).get('hpe-webhook-signature', '')
177+
if not signature_header.startswith('sha256='):
178+
return False
179+
expected_signature = signature_header[7:] # Remove 'sha256=' prefix
180+
# Calculate expected signature
181+
payload = self.request['payload']
182+
calculated_signature = hmac.new(
183+
key=self.webhook_secret.encode('utf-8'),
184+
msg=payload.encode('utf-8'),
185+
digestmod=hashlib.sha256
186+
).hexdigest()
187+
# Compare signatures
188+
return hmac.compare_digest(expected_signature, calculated_signature)
189+
except Exception:
190+
return False
191+
def _forward_to_hec(self, event_data):
192+
"""Forward validated event data to Splunk HEC"""
193+
try:
194+
# Prepare HEC request
195+
hec_data = {
196+
"event": event_data,
197+
"sourcetype": "hpe:greenlake:webhook",
198+
"source": "hpe_greenlake",
199+
"index": "main" # Configure as needed
200+
}
201+
# Create HTTP request to HEC
202+
req = urllib.request.Request(
203+
url=self.hec_url,
204+
data=json.dumps(hec_data).encode('utf-8'),
205+
headers={
206+
'Authorization': f'Splunk {self.hec_token}',
207+
'Content-Type': 'application/json'
208+
}
209+
)
210+
# Send to HEC
211+
with urllib.request.urlopen(req) as response:
212+
if response.status == 200:
213+
self.response.setHeader('content-type', 'application/json')
214+
self.response.write(json.dumps({"status": "success"}))
215+
return
216+
else:
217+
return self._return_error("Failed to forward to HEC", 500)
218+
except Exception as e:
219+
return self._return_error(f"HEC forwarding failed: {str(e)}", 500)
220+
def _return_error(self, message, status_code):
221+
"""Return error response"""
222+
self.response.setStatus(status_code)
223+
self.response.setHeader('content-type', 'application/json')
224+
self.response.write(json.dumps({"error": message}))
225+
```
226+
227+
## Configuration files
228+
229+
### default/restmap.conf
230+
231+
`[script:hpe_webhook_handler]`
232+
`match = /hpe/webhook`
233+
`script = hpe_webhook_handler.py`
234+
`scripttype = persist`
235+
`handler = hpe_webhook_handler.HPEWebhookHandler`
236+
`requireAuthentication = false`
237+
`output_modes = json`
238+
`passPayload = true`
239+
`passHttpHeaders = true`
240+
`passHttpCookies = false`
241+
242+
### default/web.conf
243+
244+
`[expose:hpe_webhook_handler]
245+
pattern = hpe/webhook
246+
methods = POST`
247+
248+
### metadata/default.meta
249+
250+
`[restmap/hpe_webhook_handler]
251+
export = system
252+
[views]
253+
export = system`
254+
255+
# Configuring Splunk HTTP Event Collector (HEC)
256+
257+
You need to create an API token to use HEC via its API. You can do this from:
258+
259+
1.    **Settings > Data Inputs > HTTP Event Collector**
260+
261+
**2.**    Select **New token.** Use this token to update the Python handler script line
262+
263+
Picture 1
264+
265+
Your final configuration should look like this:
266+
267+
Picture 2
268+
269+
Verify your global settings so that they match the following:
270+
271+
Picture 3
272+
273+
This allows you to get your HEC endpoint, which is used in the Python handler to create an incident based on the HPE GreenLake event received via the webhook. The URL of the endpoint should look like this:
274+
275+
`<https://<splunk-host>>:8088/services/collector/event`
276+
277+
 Don’t forget to modify the Python handler (shown above) line 7 accordingly.
278+
279+
# Final integration flow
280+
281+
The complete integration flow works as follows:
282+
283+
1. Initial setup
284+
285+
* Deploy the custom Splunk endpoint handler using the above HPE webhook handler Python script.
286+
* Make sure to set HEC token and webhook secret in the Python script.
287+
* Register the webhook handler URL with HPE GreenLake: <https://your-splunk-instance:8089/servicesNS/-/your_app/hpe/webhook>
288+
289+
> Note: See [this blog](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/) to learn how to register a new webhook handler in HPE GreenLake
290+
291+
2. Webhook handler verification process
292+
3. Event processing flow
293+
294+
* HPE GreenLake sends event data to the custom handler endpoint.
295+
* The custom REST handler validates the HMAC signature.
296+
* The handler forwards validated events to HEC.
297+
* Splunk HEC ingests the data for analysis and visualization.
298+
299+
4. Data flow diagram
300+
301+
`HPE GreenLake → Custom REST Endpoint → Validation → HEC → Splunk Index`
302+
`↓           ↓                ↓      ↓     ↓`
303+
`Events     Challenge       Verify   Ingest   Analyze`
304+
` Response       Signature   Data Visualize`
305+
306+
# Benefits of this architecture
307+
308+
Security: The custom endpoint handler ensures only validated, authentic events reach your Splunk environment.
309+
310+
Reliability: If there are more than 20 failures in a 12-hour period, the webhook enters the critical state in HPE GreenLake. If there are no new failures in 12 hours, the webhook returns to the active state. The custom handler can implement robust error handling to maintain webhook health.
311+
312+
Scalability: The solution can handle multiple webhook types and route them to different HEC endpoints or indexes as needed.
313+
314+
Monitoring: All webhook interactions are logged within Splunk for troubleshooting and monitoring.
315+
316+
# Testing and deployment
317+
318+
Testing the integration
319+
320+
1. Verify custom endpoint: Test your custom REST endpoint using curl:
321+
322+
`curl -X POST `[`https://your-splunk-instance:8089/servicesNS/-/your_app/hpe/webhook`](https://your-splunk-instance:8089/servicesNS/-/your_app/hpe/webhook)` \`
323+
`-H "Content-Type: application/json" \`
324+
`-d '{"type": "test.event", "data": {"message": "Hello Splunk"}}'`
325+
326+
2. Webhook registration: Register your webhook with HPE GreenLake using the custom endpoint URL.
327+
3. Challenge validation: Monitor Splunk logs to ensure the challenge request is handled correctly.
328+
4. Event flow testing: Trigger test events from HPE GreenLake and verify they appear in your Splunk index.
329+
330+
# Conclusion
331+
332+
Integrating HPE GreenLake webhooks with Splunk via HTTP Event Collector presents unique challenges due to the webhook verification requirements, but Splunk's custom REST endpoints capabilities provide an elegant solution. Such integration offers several key benefits:
333+
334+
Enhanced security: The custom REST endpoint handler ensures that only validated, authentic events from HPE GreenLake reach your Splunk environment, maintaining the security standards required by both platforms.
335+
336+
Seamless event flow: Once configured, events flow automatically from HPE GreenLake to Splunk, enabling real-time monitoring and analysis of your cloud infrastructure.
337+
338+
Extensible architecture: The custom REST handler can be extended to support multiple webhook types, different routing logic, and additional validation mechanisms as your requirements evolve.
339+
340+
Whether you're monitoring subscription changes, or audit events, this integration ensures that your HPE GreenLake data becomes a valuable part of your Splunk analytics ecosystem, empowering your organization with comprehensive, real-time insights into your cloud infrastructure.

0 commit comments

Comments
 (0)