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

Feature/support all dimensions #76

Merged
merged 9 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ target/
.idea
logs
bin/
.vscode
.vscode
test-utils/
2 changes: 2 additions & 0 deletions datadog-monitoring-integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mql_reference/
.env
40 changes: 35 additions & 5 deletions datadog-monitoring-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ memory: 256
config:
DATADOG_METRICS_API_ENDPOINT: <your-datadog-metrics-api-endpoint>
DATADOG_API_KEY: <your-datadog-api-key>
# Optional - default value
FORWARD_TO_DATADOG: True
METRICS_TAG_KEYS: name, namespace, displayName, resourceDisplayName, unit
LOGGING_LEVEL: DEBUG
ENABLE_TRACING: False
```

deploy function
Expand All @@ -40,3 +35,38 @@ export DATADOG_API_KEY=<your-datadog-api-key>

python3 func.py
```

## Configs

- Required
- DATADOG_METRICS_API_ENDPOINT
- DATADOG_API_KEY
- Optional
- FORWARD_TO_DATADOG
- METRICS_TAG_KEYS
- LOGGING_LEVEL
- ENABLE_TRACING

### DATADOG_METRICS_API_ENDPOINT

You can check the metrics endpoint: [https://docs.datadoghq.com/ja/api/latest/metrics/](https://docs.datadoghq.com/ja/api/latest/metrics/)

### DATADOG_API_KEY

Obtain your Datadog API KEY and set value.

### FORWARD_TO_DATADOG

Whether to forward metrics to Datadog. Mainly used for debug purposes.

### METRICS_TAG_KEYS

Tag information to be linked to Datadog. By default, almost all dimension is converted to Tag and linked.

### LOGGING_LEVEL

Log level.

### ENABLE_TRACING

Whether to output the contents of the Exception to the stack trace or not.
3 changes: 2 additions & 1 deletion datadog-monitoring-integration/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
api_endpoint = os.getenv('DATADOG_METRICS_API_ENDPOINT', 'not-configured')
api_key = os.getenv('DATADOG_API_KEY', 'not-configured')
is_forwarding = eval(os.getenv('FORWARD_TO_DATADOG', "True"))
metric_tag_keys = os.getenv('METRICS_TAG_KEYS', 'name, namespace, displayName, resourceDisplayName, unit')
all_tag_keys = 'accountSubscription, action, actionType, adapterIdentifier, agentHostName, aggregateDataMeasure, apdexLevel, apmrumPageUpdateType, apmrumType, apmVersion, applicationId, applicationName, appserver, appserverDisplayPort, appserverDomainName, appserverId, appserverName, appserverPorts, appserverServerName, appserverType, appserverVersion, associatedOciResourceId, associatedResourceId, attachmentId, availabilityDomain, backendHttpStatusCategory, backendHttpStatusCode, backendName, backendSetName, backendType, browserName, buildPipelineId, cause, clientName, clusterId, collectionName, compartmentId, component, computeMaintenanceAction, connectorId, connectorName, countryCode, createdBy, customMarker, dataProcessingFrequencyInHrs, dataType, dbSystemId, dBUniqueName, deploymentId, deploymentName, deploymentType, deployPipelineId, deployStageId, deployStageName, deviceType, diskgroupName, displayName, distributionPathName, dropType, ebsAkRegionAppId, ebsAkRegionCode, ebsClassName, ebsFunctionId, ebsOaFunc, ebsOahp, ebsOapb, ebsOasf, ebsRegionAppId, ebsRegionClass, ebsRegionCode, ebsRespAppId, ebsRespId, endpointType, entitlementName, errorCategory, errorCode, errorMessage, errorSeverity, errorType, eventType, exceededForecastWindow, executorId, extractName, faultClass, faultDomain, filesystemName, fleetName, flowCode, flowVersion, forecastModel, genre, ggregateDataMeasure, healthItem, heatWaveNode, host, hostAddress, hostAddresses, hostname, hostnameCanonical, hostnames, httpMethodType, httpStatusCategory, httpStatusCode, imageId, inboundProcessingEndpointInformation, inboundProcessingResponseStatus, instanceId, instanceName, instanceNumber, instancePoolId, integrationFlowIdentifier, ioType, isApmAgentMonitored, isDegraded, isHarAvailable, isIncreasingCpu, isIncreasingIo, isIncreasingWait, isInefficient, isLogAvailable, isNetworkDataAvailable, isPlanChanged, isRetryExecution, isScreenshotAvailable, isVariant, isVisible, javaMajorVersion, javaVendor, javaVersion, jobId, jobName, kubernetesNamespace, kubernetesNodeName, kubernetesPodAnnotations, kubernetesPodLabels, kubernetesPodName, lbComponent, lbHostId, lifecycleState, listenerName, logGroupId, logGroupName, logObjectId, logObjectName, logSourceService, maintenanceDueTime, maintenanceWindowActive, managedDatabaseGroupId, managedDatabaseId, memoryPool, memoryType, meshComponent, meshId, metadataVersion, meterType, module, monitorId, monitorName, monitorType, mountTargetId, mtResourceName, nodeCondition, nodepoolId, nodeState, obcResourceName, ociAvailabilityDomain, ociCompartmentId, ociComputeShape, ociDisplayName, ociFaultDomain, ociInstanceId, ociRegion, okeClusterId, okeClusterLabel, okeCompartmentName, okeKubernetesVersion, okeNodePoolId, okeNodepoolLabel, okeTenancyId, operation, oraPackagedApp, osAvailableProcessors, osFamily, osName, osUserName, osVersion, outboundInvocationEndpointInformation, outboundInvocationResponseStatus, parentResourceId, parseType, partitionId, path, performanceFactorName, performanceFactorType, primaryDomain, probe, processId, processName, projectId, projectName, protocol, publicIp, pullType, pushType, queueName, receiverPathName, recommendedAction, region, replicatName, repositoryId, repositoryName, repositoryType, requestType, resourceDisplayName, resourceDomain, resourceId, resourceMetric, resourceName, resourceType, responseCacheResult, responseCode, responseCodeGroup, responseGroup, responseType, result, resultCode, resultMessage, riskLevel, route, schemaName, serviceInstanceId, serviceName, sessionType, shape, siebelResourceName, siebelResourceOperation, siebelResourceType, size, sourceEntityIdentifier, sourceIdentifier, sourceMetricName, sourceName, srcType, stageId, stageType, status, statusCode, statusFamily, subscriberId, subscriberName, subscriptionId, tableName, tablespaceName, tablespaceType, target, targetName, taskId, taskName, taskStatus, taskType, telemetryAutoVersion, telemetrySdkLanguage, telemetrySdkName, telemetrySdkVersion, telemetrySourceEntityIdentifier, telemetrySourceIdentifier, telemetrySourceType, throughput, tier, timestamp, topicDisplayName, transactionStatus, type, usagePlanId, usagePlanName, userAgent, userTenancyId, vantagePoint, vantagePointDisplayName, version, vmName, vmVendor, vmVersion, waitClass, webApplicationName, workingDirectory, workspaceId'
metric_tag_keys = os.getenv('METRICS_TAG_KEYS', all_tag_keys)
metric_tag_set = set()

# Set all registered loggers to the configured log_level
Expand Down
9 changes: 2 additions & 7 deletions datadog-monitoring-integration/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ run_image: fnproject/python:3.9
entrypoint: /python/bin/fdk /function/func.py handler
memory: 256
config:
DATADOG_METRICS_API_ENDPOINT: <your-datadog-metrics-api-endpoint>
DATADOG_API_KEY: <your-datadog-api-key>
# Optional - default value
FORWARD_TO_DATADOG: True
METRICS_TAG_KEYS: name, namespace, displayName, resourceDisplayName, unit
LOGGING_LEVEL: DEBUG
ENABLE_TRACING: False
DATADOG_API_KEY:
DATADOG_METRICS_API_ENDPOINT:
33 changes: 33 additions & 0 deletions greeting-java/build_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 0.1
component: build
timeoutInSeconds: 10000
shell: bash
failImmediatelyOnError: true
env:
variables:
function_name: greeting-java
function_version: 0.0.1
exportedVariables:
- tag

steps:
- type: Command
name: "build function image"
shell: bash
timeoutInSeconds: 650
failImmediatelyOnError: true
command: |
cd greeting-java
fn build
docker tag ${function_name}:${function_version} ${function_name}
tag=${function_version}
onFailure:
- type: Command
command: |
echo "Failure successfully handled"
timeoutInSeconds: 400

outputArtifacts:
- name: greeting-java-image
type: DOCKER_IMAGE
location: greeting-java
3 changes: 1 addition & 2 deletions greeting-java/src/main/java/me/shukawam/fn/EntryPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public class EntryPoint {
public Response handleRequest(String name) {
var message = (name == null || name.isEmpty()) ? "world" : name;
return new Response("Hello " + message);
return new Response("Hi there.");
}
}