|
| 1 | +<!-- |
| 2 | +Copyright (c) 2025 Oracle and/or its affiliates. |
| 3 | +
|
| 4 | +The Universal Permissive License (UPL), Version 1.0 |
| 5 | +
|
| 6 | +Subject to the condition set forth below, permission is hereby granted to any |
| 7 | +person obtaining a copy of this software, associated documentation and/or data |
| 8 | +(collectively the "Software"), free of charge and under any and all copyright |
| 9 | +rights in the Software, and any and all patent rights owned or freely |
| 10 | +licensable by each licensor hereunder covering either (i) the unmodified |
| 11 | +Software as contributed to or provided by such licensor, or (ii) the Larger |
| 12 | +Works (as defined below), to deal in both |
| 13 | +
|
| 14 | +(a) the Software, and |
| 15 | +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if |
| 16 | +one is included with the Software (each a "Larger Work" to which the Software |
| 17 | +is contributed by such licensors), |
| 18 | +
|
| 19 | +without restriction, including without limitation the rights to copy, create |
| 20 | +derivative works of, display, perform, and distribute the Software and make, |
| 21 | +use, sell, offer for sale, import, export, have made, and have sold the |
| 22 | +Software and the Larger Work(s), and to sublicense the foregoing rights on |
| 23 | +either these or other terms. |
| 24 | +
|
| 25 | +This license is subject to the following condition: |
| 26 | +The above copyright notice and either this complete permission notice or at |
| 27 | +a minimum a reference to the UPL must be included in all copies or |
| 28 | +substantial portions of the Software. |
| 29 | +
|
| 30 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 31 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 32 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 33 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 34 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 35 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 36 | +SOFTWARE. |
| 37 | +--> |
| 38 | + |
| 39 | +# OCI Container Instances Grafana and Prometheus example with Java Sprinboot |
| 40 | +## With multiple volumes and a custom sidecar to tail access log to OCI Logging and mount the Grafana and Prometheus configs from OCI Object Storage bucket for live changes |
| 41 | + |
| 42 | +Reviewed: 4.12.2025 |
| 43 | + |
| 44 | +## When to use this asset? |
| 45 | + |
| 46 | +Anyone who wants to experiment with OCI Container Instances and setup a multi-container instance with multiple volumes and have a setup for Prometheus and Grafana. Including: |
| 47 | + |
| 48 | +<ul> |
| 49 | +<li>Node exporter for the OCI container instance metrics</li> |
| 50 | +<li>Spring Boot Java exporter for app metrics</li> |
| 51 | +<li>Logs are exported to OCI Logging with a custom sidecar. Springboot app log is configured to <code>resources/application.properties</code> as <code>/var/log/app.log</code></li> |
| 52 | +<li>Custom sidecar also pulls configs in 30s intervals from a Object Storage private bucket for easy config changes to <code>/etc</code> of Prometheus and Grafana containers' shared volume</li> |
| 53 | +</ul> |
| 54 | + |
| 55 | +## Author |
| 56 | +<a href="https://github.com/mikarinneoracle">mikarinneoracle</a> |
| 57 | + |
| 58 | +## How to use this asset? |
| 59 | + |
| 60 | +## Build containers |
| 61 | + |
| 62 | +Build containers with GitHub Actions <code>containers.yml</code>pipeline |
| 63 | +<p> |
| 64 | + |
| 65 | +This requires three secrets: |
| 66 | +<pre> |
| 67 | +DOCKER_USERNAME |
| 68 | +AUTH_TOKEN |
| 69 | +TENANCY_NAMESPACE |
| 70 | +</pre> |
| 71 | + |
| 72 | +It uses <code>FRA</code> region for OCIR, i.e. Registry is <code>fra.ocir.io</code> |
| 73 | + |
| 74 | +## Create object storage bucket with Prometheus and Grafana configs |
| 75 | + |
| 76 | +Bucket name: <code>prometheus-grafana</code> (default, can be changed when deploying the Stack) |
| 77 | +<p> |
| 78 | +Directories in the bucket: |
| 79 | +<pre> |
| 80 | +├── grafana/ |
| 81 | +│ └── provisioning/ |
| 82 | +│ ├── dashboards/ |
| 83 | +│ └── datasources/ |
| 84 | +└── prometheus/ |
| 85 | +</pre> |
| 86 | +Upload files from <code>object-storage</code> to the directory structure above in the bucket. |
| 87 | +<p> |
| 88 | +<b>Note!</b> Remember to change the <code>username</code> and <code>password</code> in <code>grafana.ini</code> before uploading! |
| 89 | + |
| 90 | +## Deploy the Container Instances with the Terraform Stack |
| 91 | + |
| 92 | +Deploy the Container Instances stack with OCI Resource Manager (Terraform). First clone this repo to localhost and drag-drop the terraform folder to OCI Resource Manager to create a new Stack. Then configure the stack and apply. |
| 93 | +<p> |
| 94 | + |
| 95 | +Subnet ports can be opened for the following access: |
| 96 | +<ul> |
| 97 | + <li>8080 for the Springboot app</li> |
| 98 | + <li>3000 for Grafana</li> |
| 99 | + <li>9090 for Prometheus (optional)</li> |
| 100 | +</ul> |
| 101 | +<p> |
| 102 | + |
| 103 | +For taking this to a a quick spin, you can create/use a VCN with a public subnet to have public access to Grafana. |
| 104 | +VCN and subnet creation including the ports above is manual and not included in the Terraform Stack. |
| 105 | +<p> |
| 106 | + |
| 107 | +Also the OCI Log needs to be created manually for logging. |
| 108 | +<p> |
| 109 | + |
| 110 | +Once created git clone this repo and drag&drop the terraform folder to OCI Resource Manager when creating a new Stack. |
| 111 | +Then, configure the stack vars and apply to have the stack deployed for testing. Destroy and delete after finishing the test. |
| 112 | + |
| 113 | + |
| 114 | +## Useful Links |
| 115 | + |
| 116 | +- [OCI Container Instances](https://www.oracle.com/cloud/cloud-native/container-instances/) |
| 117 | + - Learn how OCI Container Instances lets you easily run applications on serverless compute optimized for containers |
| 118 | +- [OCI SDK](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdks.htm) |
| 119 | + - Oracle Cloud Infrastructure provides a number of Software Development Kits (SDKs) and a Command Line Interface (CLI) to facilitate development of custom solutions |
| 120 | +- [OCI Logging](https://docs.oracle.com/en-us/iaas/Content/Logging/Concepts/loggingoverview.htm) |
| 121 | + - The Oracle Cloud Infrastructure Logging service is a highly scalable and fully managed single pane of glass for all the logs in your tenancy. Logging provides access to logs from Oracle Cloud Infrastructure resources |
| 122 | +- [OCI Object Storage](https://www.oracle.com/cloud/storage/object-storage/) |
| 123 | + - Oracle Cloud Infrastructure (OCI) Object Storage provides scalable, durable, low-cost storage for any type of data. Benefit from 11 nines of durability. Scale storage to nearly unlimited capacity for your unstructured data |
| 124 | +- [Oracle](https://www.oracle.com/) |
| 125 | + - Oracle Website |
| 126 | + |
| 127 | +## License |
| 128 | + |
| 129 | +Copyright (c) 2025 Oracle and/or its affiliates. |
| 130 | + |
| 131 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 132 | + |
| 133 | +See [LICENSE](LICENSE) for more details. |
| 134 | + |
| 135 | +ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK. |
0 commit comments