Skip to content

Commit

Permalink
Merge pull request #22 from forestmvey/dev-additional-logging-functio…
Browse files Browse the repository at this point in the history
…nality

Adding Log Level to Environment Variables in CFN Template
  • Loading branch information
forestmvey authored Apr 29, 2024
2 parents f05cd61 + 6d5bbee commit 3dbe15c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ User-Agent: Prometheus Connector/<version> aws-sdk-go/<version> (go<version>; <o
PromQL also supports regex, here is an example:
```
prometheus_http_requests_total{handler!="/api/v1/query", job=~"p*", code!~"2..", prometheusDatabase="prometheusDatabase", prometheusMetricsTable="prometheusMetricsTable"}
prometheus_http_requests_total{handler!="/api/v1/query", job=~"p*", code!~"2.."}
```
This example queries all rows from `prometheusMetricsTable` of `prometheusDatabase` where:
Expand Down
Binary file modified documentation/example/query_example.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions serverless/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Parameters:
Type: "String"
Default: "LambdaExecutionPolicy"
Description: "The name of the basic execution policy created for AWS Lambda."
LogLevel:
Type: "String"
Default: "info"
Description: "The output level for logs. Valid values include info, warn, debug, error"

Resources:
IAMLambdaRole:
Expand Down Expand Up @@ -90,6 +94,7 @@ Resources:
default_database: !Ref "DefaultDatabase"
default_table: !Ref "DefaultTable"
region: !Ref "AWS::Region"
log_level: !Ref "LogLevel"
Events:
WriteApi:
Type: HttpApi
Expand Down
3 changes: 3 additions & 0 deletions timestream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ func (wc *WriteClient) Write(req *prompb.WriteRequest, credentials *credentials.
duration := time.Since(begin).Seconds()
if err != nil {
sdkErr = wc.handleSDKErr(req, err, sdkErr)
} else {
LogInfo(wc.logger, fmt.Sprintf("Successfully wrote %d records to database: %s table: %s", len(writeRecordsInput.Records), database, table))
}
wc.writeExecutionTime.Observe(duration)
wc.writeRequests.Inc()
Expand Down Expand Up @@ -260,6 +262,7 @@ func (qc *QueryClient) Read(req *prompb.ReadRequest, credentials *credentials.Cr
LogError(qc.logger, "Error occurred while converting the Timestream query results to Prometheus QueryResults", err)
return false
}
LogInfo(qc.logger, fmt.Sprintf("Successfully read %d records from database: %s table: %s", len(page.Rows), qc.client.defaultDataBase, qc.client.defaultTable))
return true
})
if queryPageError != nil {
Expand Down

0 comments on commit 3dbe15c

Please sign in to comment.