Google-cloud-dotnet: MonitoredResource logs not showing up under the monitored resource

Created on 29 Aug 2018  路  6Comments  路  Source: googleapis/google-cloud-dotnet

https://github.com/logary/logary/blob/master/src/targets/Logary.Targets.Stackdriver/Target_Stackdriver.fs#L110

Repro: dotnet build and dotnet run here https://github.com/logary/logary/tree/master/src/tests/Logary.Targets.Stackdriver.Tests with another resource here https://github.com/logary/logary/blob/master/src/tests/Logary.Targets.Stackdriver.Tests/Program.fs#L52

In case a more extensive repro is needed; this issue can be to document how to e.g. log to a container resource in GKE; right now this repo only contains tests for the global resource and all that the docs show is the global resource (which does work).

p1 investigating bug

All 6 comments

@haf I'm off for the rest of the week, but will take a look at this early next week when I'm back.

I think this might be a symptom of googleapis/gax-dotnet#276 .

@amanda-tarafa Sounds plausible, but we read the metadata ourselves and parse it on app start, if we set them as part of the resource, explicitly. Did you try just creating a console app and sending another source? Because I haven't tested this issue in a few months and things may have changed.

@haf I'm looking into this issue right now. I'll update here when I have more info and have confirmed or not if the 2 issues are related.

@haf I've ran the following code (basically logary's own F# Hello World example tweaked to use Stackdriver as a target) and I can confirm that the entry does not appear under Global but under the proper GKE container, and all the labels for the resource have their correct value. That is I can't reproduce the issue.
As you can see the values I used are hard-coded, but I got them from a test cluster I have running on GCP. I ran it with made up values as well, not corresponding to any cluster I have on GCP, and the entry got logged properly under those made up values. So I suspect that your trouble is around how you are getting those values, which might be due to googleapis/gax-dotnet#276 or another issue on our side, or maybe an issue on your side. I haven't found code on your repo that is trying to obtain that metadata so I cannot tell for sure where the issue might be. If you are able to reproduce it again, please send as a stripped down version of the code as possible so I can take a look.
The code I ran:

let logger = Log.create "Hello World logger"

[<EntryPoint>]
let main argv =
    use mre = new System.Threading.ManualResetEventSlim(false)
    use sub = Console.CancelKeyPress.Subscribe (fun _ -> mre.Set())

    let projectId = "cloudsharptest"

    let logname = "logary-testing-log"

    let resource = Container("cluster-1", "kube-system", "2984358405818061623", "heapster-v1.5.2-56fb496965-8w9rp", "heapster-nanny", "europe-west1-b")

    let conf = StackdriverConf.create(projectId, logname, resource)

    let logary =
        Config.create "Logary.ConsoleApp" "localhost"
        |> Config.target (Stackdriver.create conf "target-name")
        |> Config.build
        |> Hopac.Hopac.run

    logger.info (eventX "testing logary")

    mre.Wait()

    0 // return an integer exit code

And the entry correctly logged (sorry for the shapeless red blobs):
image

@amanda-tarafa That is great! Now we can also improve Rutta to ship into the GCP Compute Instance resource :) /cc @akselsson

Thank you very much for validating this behaviour. I'm going to validate it on my side and ship those improvements to Logary/Rutta.

Was this page helpful?
0 / 5 - 0 ratings