Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new MetricRepository to read and write data via REST #445

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cmachgodaddy
Copy link

Issue #, if available:

Description of changes:

Adding new MetricRepository to read and write data via REST

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@cmachgodaddy
Copy link
Author

@shehzad-qureshi @eycho-am @sseb @sseb Can you review this PR?

@rdsharma26
Copy link
Contributor

Thank you for the pull request. Can you please share more details about your use case? Can you also attach any testing evidence that showcases how the changes work?

@rdsharma26
Copy link
Contributor

@cmachgodaddy Can you provide an update on my comment above?

@cmachgodaddy
Copy link
Author

Hi @rdsharma26 , sorry for the late response. My use case was as bellow:
I have a Dynamo DB table, which has a metric table, which contains all of the metric values output from the Deeque so far. And those metrics written by our API to the Dynamo. So, I added this repo as REST, instead of a direct Dynamo ingression.

Another reason it has to be API is our existing metric has its own schema which is not compatible with the schema that Deequ's Anomaly Detection expected. So providing this API as a abstraction layer has the flexibility to convert the schema from one format to another.

I have used this REST repo for a while now, and in production, and it works quite well. Here is how I used it

    val ENDPOINT = apiHelper.get.dlmsURL
    val PATH = s"/v1/accounts/${getAccountId()}/databases/${config.database}/tables/${config.table}/xxx"
    val headers = Map(
      "Content-Type" -> "application/json",
      "Authorization" -> s"sso-jwt xxx"
    )

    val writeRequest = new DefaultRequest[Void]("execute-api")
    writeRequest.setHttpMethod(HttpMethodName.POST)
    writeRequest.setEndpoint(URI.create(ENDPOINT))
    writeRequest.setResourcePath(PATH)
    writeRequest.setHeaders(headers.asJava)

    val readRequest = new DefaultRequest[Void]("execute-api")
    readRequest.setHttpMethod(HttpMethodName.GET)
    readRequest.setEndpoint(URI.create(ENDPOINT))
    readRequest.setResourcePath(PATH)
    readRequest.setHeaders(headers.asJava)
    val repo = new RestMetricsRepository(readRequest, writeRequest)

And, here is how I run the Anomaly Detection job, and send data to Dynamo

      val verificationResult = VerificationSuite()
        .onData(dataDF)
        .useRepository(repo)
        .saveOrAppendResult(todaysKey)
        .addAnomalyCheck(strategyObj, metricObj)
        .run()

These should be in the PR, btw.

I can't snapshot the results in my Dynamo, since it contains some sensitive data. But, the changes in this PR should be very straightforward? it based off the existing patterns of the FileSystem and the InMemory repos.

Let me know if you need anything else to get this PR in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants