Skip to content

Commit

Permalink
Cherry-pick: Add support for specifying sinkoptions when creating sta…
Browse files Browse the repository at this point in the history
…ckdriver sink (istio#9199)

* Add support for specifying sinkoptions when creating stackdriver sink

* Lint fix

* Dep fix
  • Loading branch information
douglas-reid authored and istio-testing committed Oct 11, 2018
1 parent ffd5b50 commit 1d05c01
Show file tree
Hide file tree
Showing 25 changed files with 736 additions and 277 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,49 @@ <h2 id="Params-LogInfo-SinkInfo">Params.LogInfo.SinkInfo</h2>
<td>
<p>Filter that specifies any filtering to be done on logs.</p>

</td>
</tr>
<tr id="Params-LogInfo-SinkInfo-UniqueWriterIdentity">
<td><code>UniqueWriterIdentity</code></td>
<td><code>bool</code></td>
<td>
<p>Determines the kind of IAM identity returned as WriterIdentity in the new
sink. If this value is omitted or set to false, and if the sink&rsquo;s parent is a
project, then the value returned as WriterIdentity is the same group or
service account used by Stackdriver Logging before the addition of writer
identities to the API. The sink&rsquo;s destination must be in the same project as
the sink itself.</p>

<p>If this field is set to true, or if the sink is owned by a non-project
resource such as an organization, then the value of WriterIdentity will
be a unique service account used only for exports from the new sink.</p>

</td>
</tr>
<tr id="Params-LogInfo-SinkInfo-UpdateDestination">
<td><code>UpdateDestination</code></td>
<td><code>bool</code></td>
<td>
<p>These fields apply only to UpdateSinkOpt calls. The corresponding sink field
is updated if and only if the Update field is true.
Upate sink destination.</p>

</td>
</tr>
<tr id="Params-LogInfo-SinkInfo-UpdateFilter">
<td><code>UpdateFilter</code></td>
<td><code>bool</code></td>
<td>
<p>Update sink filter.</p>

</td>
</tr>
<tr id="Params-LogInfo-SinkInfo-UpdateIncludeChildren">
<td><code>UpdateIncludeChildren</code></td>
<td><code>bool</code></td>
<td>
<p>Update includes children.</p>

</td>
</tr>
</tbody>
Expand All @@ -324,12 +367,16 @@ <h2 id="Params-MetricInfo">Params.MetricInfo</h2>
<td><code>kind</code></td>
<td><code><a href="#google-api-MetricDescriptor-MetricKind">google.api.MetricDescriptor.MetricKind</a></code></td>
<td>
<p>The kind of measurement for a metric, which describes how the data is reported. Ex: Gauge.</p>

</td>
</tr>
<tr id="Params-MetricInfo-value">
<td><code>value</code></td>
<td><code><a href="#google-api-MetricDescriptor-ValueType">google.api.MetricDescriptor.ValueType</a></code></td>
<td>
<p>The type of the metric&rsquo;s value. Ex: Distribution.</p>

</td>
</tr>
<tr id="Params-MetricInfo-buckets">
Expand Down
312 changes: 237 additions & 75 deletions mixer/adapter/stackdriver/config/config.pb.go

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions mixer/adapter/stackdriver/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ message Params {
// Describes how to represent an Istio metric in Stackdriver.
// See https://github.com/googleapis/googleapis/blob/master/google/api/metric.proto
message MetricInfo {
// The kind of measurement for a metric, which describes how the data is reported. Ex: Gauge.
google.api.MetricDescriptor.MetricKind kind = 1;
// The type of the metric's value. Ex: Distribution.
google.api.MetricDescriptor.ValueType value = 2;

// Describes buckets for DISTRIBUTION valued metrics.
Expand Down Expand Up @@ -223,6 +225,26 @@ message Params {
string destination = 2;
// Filter that specifies any filtering to be done on logs.
string filter = 3;
// Determines the kind of IAM identity returned as WriterIdentity in the new
// sink. If this value is omitted or set to false, and if the sink's parent is a
// project, then the value returned as WriterIdentity is the same group or
// service account used by Stackdriver Logging before the addition of writer
// identities to the API. The sink's destination must be in the same project as
// the sink itself.
//
// If this field is set to true, or if the sink is owned by a non-project
// resource such as an organization, then the value of WriterIdentity will
// be a unique service account used only for exports from the new sink.
bool UniqueWriterIdentity = 4;

// These fields apply only to UpdateSinkOpt calls. The corresponding sink field
// is updated if and only if the Update field is true.
// Upate sink destination.
bool UpdateDestination = 5;
// Update sink filter.
bool UpdateFilter = 6;
// Update includes children.
bool UpdateIncludeChildren = 7;
}
// If SinkInfo is provided, Stackriver logs would be exported to that sink.
SinkInfo sink_info = 4;
Expand Down
Binary file modified mixer/adapter/stackdriver/config/config.proto_descriptor
Binary file not shown.
2 changes: 1 addition & 1 deletion mixer/adapter/stackdriver/config/stackdriver.yaml

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions mixer/adapter/stackdriver/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ func (b *builder) Build(ctx context.Context, env adapter.Env) (adapter.Handler,
ctx := context.Background()
var sinkErr error
// first try to CreateSink, if error is AlreadyExists then update that sink.
if _, sinkErr = syncClient.CreateSink(ctx, sink); isAlreadyExists(sinkErr) {
_, sinkErr = syncClient.UpdateSink(ctx, sink)
if _, sinkErr = syncClient.CreateSinkOpt(ctx, sink,
logadmin.SinkOptions{UniqueWriterIdentity: log.SinkInfo.UniqueWriterIdentity}); isAlreadyExists(sinkErr) {
_, sinkErr = syncClient.UpdateSinkOpt(ctx, sink,
logadmin.SinkOptions{UpdateDestination: log.SinkInfo.UpdateDestination,
UpdateFilter: log.SinkInfo.UpdateFilter,
UpdateIncludeChildren: log.SinkInfo.UpdateIncludeChildren})
}
if sinkErr != nil {
logger.Warningf("failed to create/update stackdriver logging sink: %v", sinkErr)
Expand Down
Loading

0 comments on commit 1d05c01

Please sign in to comment.