Skip to content

capturing data from Neptune change stream

0

Hi, I am exploring the bet way to capture data from Neptune change stream and pass it on downstream.

The blog below suggests authoring your own handler function and then to have that executed on a periodic basis , by a polling framework, that Neptune supplies. There is a cloud formation template that Neptune supplies ,that allows you to provision a polling framework.

https://aws.amazon.com/blogs/database/capture-graph-changes-using-neptune-streams/

My question is, can a glue job directly ingest from Neptune change stream ? or do we need to use the lambda?

If the intermediate lambda cannot be removed,what is best approach to flowing the change events to the Glue job, considering the parallel scaling of the Glue job and avoid sequential processing? And are there pros/cons of changing the downstream processing to be StepFunctions instead of Glue Streaming Jobs? Can the Neptune change stream output be consumed via airflow instead of glue? if so how.

I am looking to implement this via cdk, python (and query Neptune using openCypher).

Any advice, examples would be very much appreciated.

thanks and Regards.

2 Answers
0

AWS doesn’t have built-in change streams for Neptune yet. If you need them, consider using Neptune Streams with Lambda or polling the audit log via CloudWatch to trigger downstream actions.

answered a year ago

  • The Audit Log reflects queries and other data plane API requests that were sent to the database. It does not in any way reflect the results of any mutations driven by those requests. Trying to parse the audit log looking for anything that potentially triggered a mutation could be complex (and expensive). Your suggestion of polling the stream from something like a Lambda function, triggered perhaps by an EventBridge rule, is definitely a good approach

0

To capture data from Neptune change streams and pass it downstream, there are several approaches you can consider:

  1. Direct ingestion by Glue: Unfortunately, AWS Glue cannot directly ingest data from Neptune change streams. The Neptune Streams feature provides an HTTP REST API for retrieving change records, which is not natively compatible with Glue's input sources.

  2. Using Lambda: The approach mentioned in the blog post you referenced, using a Lambda function as an intermediary, is a common and recommended method. This Lambda function can be triggered periodically to poll the Neptune Streams API and process the change records.

  3. Alternative approaches:

    a. EventBridge Pipes: You could use Amazon EventBridge Pipes to integrate Neptune Streams with other AWS services, including AWS Step Functions or Amazon SageMaker, for more complex processing workflows.

    b. Apache Airflow: While it's possible to use Apache Airflow to consume Neptune change stream data, it would require custom operator development to interact with the Neptune Streams API.

For flowing change events to a Glue job while considering parallel scaling and avoiding sequential processing:

  1. Use a message queue: Instead of directly invoking the Glue job, have your Lambda function push change events to a message queue like Amazon SQS or Amazon Kinesis. This allows for better scalability and parallel processing.

  2. Glue Streaming Job: Configure your Glue job as a streaming job that reads from the message queue. This approach allows for parallel processing of events and can scale based on the input rate.

Regarding the use of Step Functions instead of Glue Streaming Jobs:

Pros of using Step Functions:

  • More fine-grained control over the workflow
  • Better error handling and retry mechanisms
  • Easier to implement complex processing logic

Cons of using Step Functions:

  • May introduce additional latency
  • Could be more complex to set up for simple streaming scenarios

The choice between Glue Streaming Jobs and Step Functions depends on your specific use case, complexity of processing, and latency requirements.

For implementing this via CDK with Python and using openCypher:

  1. Use the AWS CDK to define your infrastructure, including the Neptune cluster, Lambda functions, and any additional services like SQS or Kinesis.

  2. Implement the Lambda function in Python to poll the Neptune Streams API using the requests library.

  3. Use the GetSparqlStream API operation for retrieving the change stream data if you're working with RDF data, or GetPropertygraphStream for property graph data.

  4. In your Lambda function, use the neo4j Python driver to execute openCypher queries against Neptune if needed.

  5. Implement the downstream processing logic in either Glue jobs or Step Functions, depending on your chosen approach.

Remember to enable the Neptune Streams feature by setting the neptune_streams DB cluster parameter to 1, and ensure that your IAM roles have the necessary permissions to access the Neptune Streams API.
Sources
Capturing graph changes in real time using Neptune streams - Amazon Neptune
GetSparqlStream - Neptune Data API
Neptune streams dataplane API - Amazon Neptune
Choose the right change data capture strategy for your Amazon DynamoDB applications | AWS Database Blog

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.