Skip to content

Add cloud provider metadata#871

Merged
mikker merged 16 commits intoelastic:masterfrom
mikker:fetch-cloud-info
Oct 7, 2020
Merged

Add cloud provider metadata#871
mikker merged 16 commits intoelastic:masterfrom
mikker:fetch-cloud-info

Conversation

@mikker
Copy link
Copy Markdown
Contributor

@mikker mikker commented Sep 15, 2020

See #841

@mikker mikker self-assigned this Sep 15, 2020
@mikker mikker added this to the 7.10 milestone Sep 15, 2020
@ghost
Copy link
Copy Markdown

ghost commented Sep 15, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #871 updated]

  • Start Time: 2020-10-07T10:10:56.850+0000

  • Duration: 25 min 17 sec

Test stats 🧪

Test Results
Failed 0
Passed 67565
Skipped 129
Total 67694

Steps errors 5

Expand to view the steps failures

  • Name: Shell Script

    • Description: ./spec/scripts/spec.sh jruby:9.2 grape-1.3

    • Duration: 4 min 36 sec

    • Start Time: 2020-10-07T10:16:57.355+0000

    • log

  • Name: Shell Script

    • Description: [2020-10-07T10:18:12.398Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-13-

    • Duration: 7 min 30 sec

    • Start Time: 2020-10-07T10:18:12.096+0000

    • log

  • Name: Shell Script

    • Description: [2020-10-07T10:17:54.028Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-j

    • Duration: 7 min 32 sec

    • Start Time: 2020-10-07T10:17:53.737+0000

    • log

  • Name: Shell Script

    • Description: [2020-10-07T10:17:47.030Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-j

    • Duration: 4 min 34 sec

    • Start Time: 2020-10-07T10:17:46.746+0000

    • log

  • Name: Shell Script

    • Description: [2020-10-07T10:17:47.063Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-j

    • Duration: 8 min 54 sec

    • Start Time: 2020-10-07T10:17:46.777+0000

    • log

@mikker mikker marked this pull request as ready for review October 1, 2020 12:52
@felixbarny felixbarny linked an issue Oct 2, 2020 that may be closed by this pull request
@estolfo
Copy link
Copy Markdown
Contributor

estolfo commented Oct 5, 2020

Overall, it looks good but why do we have flat values for some fields while other agents (for ex python) and the documentation has embedded values? I might be missing something in the issue comments...

For example, this shows id and name being embedded under account. And python uses an embedded value here. But we use account_id and account_name.

@mikker
Copy link
Copy Markdown
Contributor Author

mikker commented Oct 5, 2020

Good catch! I just didn't want to add nested objects when storing them internally. I need to add the nested objects again when turning into json.

@mikker
Copy link
Copy Markdown
Contributor Author

mikker commented Oct 5, 2020

AWS confirmed:

{
  "metadata": {
    "service": {
      "name": "App",
      "environment": "development",
      "version": null,
      "agent": { "name": "ruby", "version": "3.10.1" },
      "framework": { "name": "Sinatra", "version": "2.1.0" },
      "language": { "name": "ruby", "version": "2.7.2" },
      "runtime": { "name": "ruby", "version": "2.7.2" }
    },
    "process": {
      "pid": 18346,
      "title": "/home/ec2-user/.rvm/gems/ruby-2.7.2/bin/rackup",
      "argv": []
    },
    "system": {
      "hostname": "ip-172-31-4-63.eu-west-1.compute.internal",
      "architecture": "x86_64",
      "platform": "linux",
      "kubernetes": {
        "namespace": null,
        "node": { "name": null },
        "pod": { "name": null, "uid": null }
      }
    },
    "labels": null,
    "cloud": {
      "provider": "aws",
      "account": { "id": "907075276364", "name": null },
      "availability_zone": "eu-west-1b",
      "instance": { "id": "i-0f0165f84e8d411be", "name": null },
      "machine": { "type": "t2.micro" },
      "project": { "id": null, "name": null },
      "region": "eu-west-1"
    }
  }
}

@mikker
Copy link
Copy Markdown
Contributor Author

mikker commented Oct 6, 2020

GCE:

{
  "metadata": {
    "service": {
      "name": "App",
      "environment": "development",
      "version": null,
      "agent": { "name": "ruby", "version": "3.10.1" },
      "framework": { "name": "Sinatra", "version": "2.1.0" },
      "language": { "name": "ruby", "version": "2.7.0" },
      "runtime": { "name": "ruby", "version": "2.7.0" }
    },
    "process": {
      "pid": 31623,
      "title": "/home/mikkelmalmberg/.rvm/gems/ruby-2.7.0/bin/rackup",
      "argv": []
    },
    "system": {
      "hostname": "instance-1",
      "architecture": "x86_64",
      "platform": "linux",
      "kubernetes": {
        "namespace": null,
        "node": "{:name=>nil}",
        "pod": "{:name=>nil, :uid=>nil}"
      }
    },
    "labels": null,
    "cloud": {
      "provider": "gcp",
      "account": { "id": null, "name": null },
      "availability_zone": "us-central1-a",
      "instance": { "id": "1558417203220877769", "name": "instance-1" },
      "machine": { "type": "projects/944210798271/machineTypes/e2-micro" },
      "project": { "id": "944210798271", "name": "brnbw-10er" },
      "region": "us-central1"
    }
  }
}

@mikker
Copy link
Copy Markdown
Contributor Author

mikker commented Oct 6, 2020

Azure:

{
  "metadata": {
    "service": {
      "name": "App",
      "environment": "development",
      "version": null,
      "agent": { "name": "ruby", "version": "3.10.1" },
      "framework": { "name": "Sinatra", "version": "2.1.0" },
      "language": { "name": "ruby", "version": "2.7.0" },
      "runtime": { "name": "ruby", "version": "2.7.0" }
    },
    "process": {
      "pid": 2209,
      "title": "/home/azureuser/.rvm/gems/ruby-2.7.0/bin/rackup",
      "argv": []
    },
    "system": {
      "hostname": "apm-test",
      "architecture": "x86_64",
      "platform": "linux",
      "kubernetes": {
        "namespace": null,
        "node": "{:name=>nil}",
        "pod": "{:name=>nil, :uid=>nil}"
      }
    },
    "labels": null,
    "cloud": {
      "provider": "azure",
      "account": { "id": "81cf7b1d-04ab-440e-9802-5d0fb07d31ce", "name": null },
      "availability_zone": "",
      "instance": {
        "id": "b06fe3ff-4294-4422-aefa-71bccbbf8a51",
        "name": "apm-test"
      },
      "machine": { "type": "Standard_B2s" },
      "project": { "id": null, "name": "apm-test_group" },
      "region": "westeurope"
    }
  }
}

Copy link
Copy Markdown
Contributor

@estolfo estolfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

it 'tries all three' do
WebMock.stub_request(:get, Metadata::CloudInfo::AWS_URI).to_timeout
WebMock.stub_request(:get, Metadata::CloudInfo::GCP_URI).to_timeout
WebMock.stub_request(:get, Metadata::CloudInfo::AZURE_URI).to_timeout
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, didn't know about the to_timeout expectation :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither! Found it when writing this PR.

@mikker mikker merged commit ad13072 into elastic:master Oct 7, 2020
@mikker mikker deleted the fetch-cloud-info branch October 7, 2020 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collect cloud identification metadata

2 participants