-
Notifications
You must be signed in to change notification settings - Fork 58
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
Can I submit metrics with a client token? (instead of api_key+app_key) #54
Comments
Is that repository dead or still maintained ? |
Hi @aguynamedben and @jaybe78, are either of you still using this and is it still a pressing need? I’ve been making a few PRs to support a client who’s using this, and maintainers have been responsive to those changes. If it’s still useful to you, I might take a look at whether this is possible (unless I miss my mark, the DataDog’s RUM packages use different APIs than this does, so I’m not totally sure a token will work without bigger changes) if I’ve got some extra time. |
I poked around at this a little, and there does not seem to be a way to use client tokens with the standard API (which we use to submit metrics) — only the RUM and browser logs (different from normal logs) APIs, which are hosted at entirely different domains and have different endpoints and parameters (e.g. RUM is at (I also couldn’t find any technical documentation on these APIs and had to dig through the browser SDK source. If you know of any actual docs, please post here.) Ultimately, it doesn’t seem like there’s a reasonable way to do this, so I’m going to close this issue. If you know more, please post here. Otherwise I recommend using DataDog’s official RUM packages if you really need client tokens. |
Not using it, thank you for asking |
Moving to v2 Metrics API seems to support client tokens. Any plans to migrate the same? |
@jayshah123 do you have some example code that successfully submits metrics to the v2 API using client tokens? I just tried, and it does not work for me. |
Yeah, actually plain submitMetrics works but submit distribution does not so probably not much we can do.
|
I could not get plain submitMetrics to work. How are you calling it with a client token? |
Using this - https://docs.datadoghq.com/api/latest/metrics/#submit-metrics (typescript example) |
Are you sure your friend was using a client token and not an API key? How are they using the client token for auth? Are they just using it for the value of That is the API endpoint I tried, and using a client token in the same way you'd use an API key did not work for me. The docs don't discuss using a client token at all, so I'd love to know if there is a different way you are supposed to use it for auth. |
Something like: import { client, v2, v1 } from '@datadog/datadog-api-client';
class DatadogClient {
private configuration = client.createConfiguration({
authMethods: {
apiKeyAuth: 'xxxCLIENT_TOKENxxx',
},
});
private metricApiInstance: v2.MetricsApi;
constructor() {
this.metricApiInstance = new v2.MetricsApi(this.configuration);
}
/**
* Submit metrics returns "Payload accepted" response
*/
public async submitMetrics(payload: v2.MetricsApiSubmitMetricsRequest) {
try {
const response = await this.metricApiInstance.submitMetrics(payload);
return response;
} catch (error) {
}
}
}
export default DatadogClient; |
That code definitely does not work with a client token. Maybe the errors got silenced by your empty try {
const response = await this.metricApiInstance.submitMetrics(payload);
return response;
} catch (error) {
} Anyway, it seems like this is not actually a thing, so there’s probably not much more to dig into here. Separately, I would be kind of surprised if Datadog did ever make this work for metrics, since you can only submit one point per second per metric per host. It’s not a very good fit for a situation with lots of uncoordinated senders, which is probably the kind of situation you are in if you need client tokens. (Distributions or events are better for this use case, and that's probably why Datadog’s Lambda package is based on distributions and its RUM package is based on events. Neither uses metrics.) |
Hi, thanks for making this library available.
I'm building an Electron app and want to collect metrics from it. The Datadog RUM/logging systems support intake using a client token, which is a write-only credential for use in the web browser and apps where source code is comprisable.
Have you found a way with the metrics APIs to submit metrics using the client token? I'm poking around but the API keeps telling me I need an api_key. Thanks for any help you could provide on this.
The text was updated successfully, but these errors were encountered: