Reputation: 15008
I'm wondering if there is a good way to export spans from Google Stackdriver to BigQuery for better analysis of traces?
The only potential solutions I'm seeing currently are writing to the trace and BigQuery APIs individually or querying the trace API on an ad hoc basis.
The first isn't great because it would require a pretty big change to the application code (I currently just use OpenCensus with Stackdriver exporter to transparently write traces to Stackdriver). The second isn't great because it's a lot of lift to query the API for spans and write them to BigQuery and it has to be done on an ad hoc basis.
A sink similar to log exporting would be great.
Upvotes: 0
Views: 471
Reputation: 715
You exporting logs to big-query , you have to create table in big-query and add data in bigquery.
By default in GCP, all logs go via stack driver.
To export logs in the big query from the stackdriver , you have to create Logger Sink using code or GCP logging UI
Then create a Sink, add a filter. https://cloud.google.com/logging/docs/export/configure_export_v2
hen add logs to stack driver using code
public static void writeLog(Severity severity, String logName, Map<String,
String> jsonMap) {
List<Map<String, String>> maps = limitMap(jsonMap);
for (Map<String, String> map : maps) {
LogEntry logEntry = LogEntry.newBuilder(Payload.JsonPayload.of(map))
.setSeverity(severity)
.setLogName(logName)
.setResource(monitoredResource)
.build();
logging.write(Collections.singleton(logEntry));
}
}
private static MonitoredResource monitoredResource =
MonitoredResource.newBuilder("global")
.addLabel("project_id", logging.getOptions().getProjectId())
.build();
Upvotes: 0
Reputation: 36
Unfortunately, at this moment there is no way to Exporting Stackdriver traces to BigQuery.
I noticed that exactly the same feature was already asked to be implemented on GCP side. GCP product team are already aware about this feature request and considering to implement this feature.
Please note that the Feature Requests are usually not resolved immediately as it depends on how many users are demanding the same feature. All communication regarding this feature request will be done inside public issue tracker 1, also you can 'star' it to acknowledge that you are interested in it, but keep in mind that there is no exact ETA.
Upvotes: 1
Reputation: 75900
Yes. It's a best practice that recommend you.
I have 3 advices:
Bonus: if you have to comply to RGPD and you have personal data in logs, be sure to list the process in your RGPD log book.
Upvotes: 0