Skip to content

Commit 24a6d00

Browse files
authored
Merge pull request #41120 from github/repo-sync
Repo sync
2 parents 1c724eb + 8fedd4f commit 24a6d00

File tree

6 files changed

+318
-3
lines changed

6 files changed

+318
-3
lines changed

content/billing/tutorials/automate-usage-reporting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ redirect_from:
66
- /billing/using-the-new-billing-platform/automating-usage-reporting
77
- /billing/managing-your-billing/automating-usage-reporting
88
versions:
9+
fpt: '*'
910
ghec: '*'
1011
topics:
1112
- Enterprise
Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
---
2+
title: 'Controlling and tracking costs at scale'
3+
intro: 'Control costs and provide granular reporting for your enterprise by mapping your company''s financial structures to cost centers and setting budgets at scale.'
4+
shortTitle: 'Control costs at scale'
5+
versions:
6+
fpt: '*'
7+
ghec: '*'
8+
topics:
9+
- Enterprise
10+
- Billing
11+
- REST
12+
permissions: 'Enterprise owners and billing managers'
13+
product: '{% data reusables.billing.cta-ghec-cost-centers %}'
14+
contentType: tutorials
15+
audience:
16+
- driver
17+
---
18+
19+
Cost centers help you track and control {% data variables.product.github %} costs by mapping them to your company's financial structure.
20+
21+
This tutorial guides you through planning, creating, and managing cost centers using both the user interface and the REST API, helping you decide which approach best fits your organization's needs.
22+
23+
## 1. Plan your cost center strategy
24+
25+
Cost centers allow you to group {% data variables.product.github %} resources—users, organizations, and repositories—for separate cost tracking and reporting. Each cost center should represent a segment of your company that you want to report on or control costs for as a separate entity.
26+
27+
If you use Azure billing, you can assign a different billing identity to each cost center.
28+
29+
### Identify the cost centers you need
30+
31+
The best strategy depends on the complexity of both your financial reporting structure and your {% data variables.product.github %} setup. Start with the simplest approach—you can always add more cost centers later.
32+
33+
Follow these steps to plan your cost centers:
34+
35+
1. **Map to financial entities**: Create one cost center for each financial entity you want to track internally (such as departments, business units, or project teams).
36+
37+
1. **Identify users**: List the users who belong to each financial entity. Assigning users directly to a cost center ensures their license and product usage is allocated correctly.
38+
39+
1. **Identify organizations**: List the organizations that belong to each financial entity. Assigning organizations to a cost center allocates their usage of actions, {% data variables.product.prodname_codespaces %}, packages, and other products correctly.
40+
41+
1. **Identify mixed ownership**: If an organization contains repositories owned by different financial entities, plan to assign individual repositories to the relevant cost centers and leave the organization unassigned.
42+
43+
> [!TIP]
44+
> If a user is directly assigned to cost center A, and indirectly part of cost center B by organization membership, all their costs for licensed products are allocated to cost center A. For more details and an example, see [AUTOTITLE](/billing/reference/cost-center-allocation).
45+
46+
## 2. Create a cost center in the UI
47+
48+
Now you'll create your first cost center using the user interface (UI) to familiarize yourself with how cost centers work. Choose one of the cost centers you've identified as an example—it's best to start with a small financial entity.
49+
50+
1. Navigate to your enterprise. For example, from [https://github.com/settings/enterprises](https://github.com/settings/enterprises?ref_product=ghec&ref_type=engagement&ref_style=text).
51+
{% data reusables.billing.enterprise-billing-menu %}
52+
1. Click **Cost centers**.
53+
1. Click **New cost center** in the upper-right corner.
54+
1. In the text box under "Name", enter the name of the financial entity you want to track costs for.
55+
1. Optionally, if this financial entity has a separate Azure subscription, you can add the Azure subscription to the cost center to charge usage directly to it. The credentials will be verified against Azure to ensure the Azure ID associated with the account is available.
56+
1. Under **Resources**, select the users, organizations, and repositories to track as part of this cost center.
57+
1. Click **Create cost center**.
58+
59+
Your new cost center is now active and usage will begin to attribute to the cost center immediately. Future billing reports will include this cost center with an entry in the `cost_center_name` column for usage allocated to it. You'll also be able to filter usage charts by this cost center.
60+
61+
## 3. Set budgets to control costs
62+
63+
Creating a cost center allows you to track costs separately for different financial entities. To actually control costs, you need to apply budgets to your cost centers.
64+
65+
### Understanding budgets
66+
67+
Budgets give you control over spending. Each budget:
68+
69+
* Applies to a single organization, repository, cost center, or your entire enterprise
70+
* Controls the monthly usage of one paid product, SKU, or group of SKUs
71+
* Can be configured to stop usage or to only alert when the budget limit is reached
72+
* Can alert account owners, billing managers, and nominated users as the budget limit is approached
73+
74+
### Calculate your cost center budget
75+
76+
If your internal financial plan allocates a single monthly budget for {% data variables.product.github %} for this cost center, you'll need to distribute it across the products this team uses.
77+
78+
1. **Calculate fixed license costs**: Add up the costs of licenses the team already uses for {% data variables.product.prodname_enterprise %}, {% data variables.product.prodname_copilot %}, {% data variables.product.prodname_GH_cs_and_sp %}.
79+
1. **Calculate variable budget**: Subtract the license costs from the internal budget. The remaining amount is what you can allocate for usage-based products beyond what's included in the plan.
80+
81+
### Create budgets for the cost center
82+
83+
Create one budget for each product, SKU, or group of SKUs that you want to control costs for.
84+
85+
1. On the "Billing and licensing tab", click {% octicon "bell" aria-hidden="true" aria-label="bell" %} **Budgets and alerts** to display the existing budgets.
86+
1. Click **New budget** to open the "New monthly budget" page.
87+
1. Under "Budget Type" select **Product-level budget**, **SKU-level budget**, or **Bundled premium requests budget**.
88+
89+
* To limit spending at the product level, in "Product-level budget", choose a product from the dropdown (for example, {% data variables.product.prodname_codespaces %}).
90+
* To limit spending at the SKU level, in "SKU-level budget", choose a product and a SKU (for example, {% data variables.product.prodname_copilot_short %} and {% data variables.product.prodname_copilot_short %} Premium Request).
91+
* To limit spending for all premium requests, use the "Bundled premium requests budget".
92+
93+
1. Click **Next: Configure budget** to display "Budget scope" and set the scope of spending for this budget to the cost center you created earlier.
94+
1. Under "Budget", set a budget amount. To stop any usage and further spending once the budget limit is reached, select **Stop usage when budget limit is reached**. This is not available for licensed-based products.
95+
96+
97+
1. To receive an alert when usage reaches 75%, 90%, and 100% of the budget target, select **Receive budget threshold alerts** under "Alerts". Account owners, billing managers, and any additional specified recipients will be notified via email. You may opt out at any time.
98+
99+
Under "Alert Recipients", select any additional recipients to receive the alerts.
100+
101+
1. Click **Create budget**.
102+
103+
### Review existing budgets for conflicts
104+
105+
After creating your cost center budgets, check existing enterprise-wide budgets to ensure they don't conflict with or override your new cost center budgets.
106+
107+
Navigate to the "Budgets and alerts" page. You'll see two lists of budgets:
108+
109+
* **Enterprise budgets**: Limits that apply to the whole enterprise account
110+
* **Other budgets**: Limits for specific repositories, organizations, or cost centers
111+
112+
#### Check enterprise budgets
113+
114+
Review whether any enterprise budgets apply to the same products or SKUs as your new cost center budgets. If an enterprise budget is very low, it might block usage for your cost center before the cost center's own budget is reached. Consider deleting or adjusting conflicting enterprise budgets.
115+
116+
#### View your cost center budgets
117+
118+
Filter the other budgets list to show a scope of **Cost Centers**. You should see your new cost center with a row for each budget you created. Initially, usage will be near zero, but within a few days you'll see costs accumulating as users and repositories consume products beyond the allowance in their plan.
119+
120+
## 4. Create a cost center with the REST API
121+
122+
Now that you understand how to create cost centers in the user interface, you can explore the REST API to see how cost centers can be created programmatically. Understanding the API helps you evaluate whether automation would benefit your organization.
123+
124+
This section demonstrates key REST API endpoints for cost center management using {% data variables.product.prodname_cli %}. For details on installing {% data variables.product.prodname_cli %} and authenticating to access these endpoints, see [AUTOTITLE](/rest/quickstart?apiVersion=2022-11-28&tool=cli).
125+
126+
> [!NOTE]
127+
> The following examples use {% data variables.product.prodname_cli %}, but you can adapt these commands to use `curl` or any HTTP client that supports REST API calls.
128+
129+
### List all existing cost centers
130+
131+
First, retrieve all cost centers in your enterprise to see what already exists. This simple request allows you to ensure that you're correctly authenticated to manage billing for your enterprise.
132+
133+
In your terminal, run the following command, replacing `ENTERPRISE` with the slug of your enterprise.
134+
135+
```shell copy
136+
gh api \
137+
-H "Accept: application/vnd.github+json" \
138+
-H "X-GitHub-Api-Version: 2022-11-28" \
139+
/enterprises/ENTERPRISE/settings/billing/cost-centers
140+
```
141+
142+
The response will include all the cost centers created in your enterprise, including the cost center you created earlier in this tutorial. In this example, the enterprise has one cost center, "Octocenter", with an organization and two users assigned.
143+
144+
```json
145+
{
146+
"costCenters": [
147+
{
148+
"id": "33635e2c-edc0-40b8-abea-261839ff73c1",
149+
"name": "Octocenter",
150+
"state": "active",
151+
"resources": [
152+
{
153+
"type": "User",
154+
"name": "monalisa"
155+
},
156+
{
157+
"type": "Org",
158+
"name": "doctocat-org"
159+
},
160+
{
161+
"type": "User",
162+
"name": "doctocat"
163+
}
164+
]
165+
}
166+
]
167+
}
168+
```
169+
170+
### Create a new cost center
171+
172+
Create a new cost center by providing a name. You'll receive a unique identifier that you'll use to manage this cost center.
173+
174+
In your terminal, run the following command, replacing `ENTERPRISE` and `NAME` with appropriate values.
175+
176+
```shell copy
177+
gh api \
178+
--method POST \
179+
-H "Accept: application/vnd.github+json" \
180+
-H "X-GitHub-Api-Version: 2022-11-28" \
181+
/enterprises/ENTERPRISE/settings/billing/cost-centers \
182+
-f 'name=NAME'
183+
```
184+
185+
The response includes the identifier for the new cost center. You'll need to use this `id` for all future operations on this cost center.
186+
187+
```json
188+
{
189+
"id": "3312fdf2-5950-4f64-913d-e734124059c9",
190+
"name": "NAME",
191+
"state": "active",
192+
"resources": []
193+
}
194+
```
195+
196+
### Add resources to the cost center
197+
198+
Assign users, organizations, and repositories to your cost center. This example shows how to add multiple users and an organization.
199+
200+
In your terminal, run the following command, replacing `COST_CENTER_ID` with the identifier from the previous step, and `ENTERPRISE`, `NAME`, and `ORG` with appropriate values.
201+
202+
```shell copy
203+
gh api \
204+
--method POST \
205+
-H "Accept: application/vnd.github+json" \
206+
-H "X-GitHub-Api-Version: 2022-11-28" \
207+
/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID/resource \
208+
--input - <<< '{
209+
"users": [
210+
"NAME-1",
211+
"NAME-2"
212+
],
213+
"organizations": [
214+
"ORG-1"
215+
]
216+
}'
217+
```
218+
219+
The response confirms the successful addition of resources. If any resources were previously assigned to a different cost center, they'll be listed in the `reassigned_resources` array.
220+
221+
```json
222+
{
223+
"message": "Resources successfully added to the cost center.",
224+
"reassigned_resources": [
225+
{
226+
"resource_type": "User",
227+
"name": "monalisa",
228+
"previous_cost_center": "Octocenter"
229+
}
230+
]
231+
}
232+
```
233+
234+
If the endpoint responds with `Problems parsing JSON`, use a JSON validator to check that the data specified in the `--input` option is valid.
235+
236+
## 5. Set budgets with the REST API
237+
238+
You can create budgets programmatically to apply spending controls to the cost centers you've created. This is particularly useful for managing usage-based costs like premium requests at scale.
239+
240+
### Create a budget for premium requests
241+
242+
This example shows how to create a SKU-level budget for {% data variables.product.prodname_copilot_short %} premium requests and apply it to your new cost center. This allows you to set a spending limit specifically for premium request usage by the resources in this cost center.
243+
244+
In your terminal, run the following command, replacing `ENTERPRISE`, `COST_CENTER_ID`, `USERNAME`, and `1000.0` with appropriate values.
245+
246+
```shell copy
247+
gh api \
248+
--method POST \
249+
-H "Accept: application/vnd.github+json" \
250+
-H "X-GitHub-Api-Version: 2022-11-28" \
251+
/enterprises/ENTERPRISE/settings/billing/budgets \
252+
-f budget_type='SkuPricing' \
253+
-f budget_product_sku='copilot_premium_request' \
254+
-f budget_scope='cost_center' \
255+
-f budget_entity_name='COST_CENTER_ID' \
256+
-F budget_amount=1000.0 \
257+
-F prevent_further_usage=true \
258+
-f budget_alerting='{"will_alert":true,"alert_recipients":["USERNAME"]}'
259+
```
260+
261+
The response confirms the budget was created and returns its configuration. Notice that this budget sets both `prevent_further_usage` and `will_alert` to `true`. The `octocat@github.com` email address will receive alerts as the budget limit is approached and usage will be blocked for cost center resources once 1000 USD is reached.
262+
263+
```json
264+
{
265+
"id": "budget-uuid-here",
266+
"budget_type": "SkuPricing",
267+
"budget_product_sku": "copilot_premium_request",
268+
"budget_scope": "cost_center",
269+
"budget_entity_name": "3312fdf2-5950-4f64-913d-e734124059c9",
270+
"budget_amount": 1000.0,
271+
"prevent_further_usage": true,
272+
"budget_alerting": {
273+
"will_alert": true,
274+
"alert_recipients": [
275+
"octocat"
276+
]
277+
}
278+
}
279+
```
280+
281+
> [!TIP]
282+
> You can create multiple budgets for the same cost center to control different products or SKUs independently. For example, you might set separate budgets for {% data variables.product.prodname_copilot_short %} premium requests, {% data variables.product.prodname_actions %} compute, and {% data variables.product.prodname_codespaces %} usage. See [AUTOTITLE](/billing/reference/product-and-sku-names).
283+
284+
## 6. Decide whether to automate
285+
286+
This tutorial has shown you two approaches to creating cost centers: using the user interface for hands-on management, and using the REST API for programmatic management. Understanding both approaches helps you decide which is right for your organization.
287+
288+
The **user interface** is ideal when you:
289+
290+
* Set up your first few cost centers
291+
* Make occasional updates to existing cost centers
292+
* Prefer visual confirmation of changes
293+
* Have a small number of cost centers to manage
294+
295+
The **REST API** is valuable when you:
296+
297+
* Need to create or update multiple cost centers regularly
298+
* Need to integrate cost center management with existing financial systems or generate configurations from external data sources
299+
* Need cost centers to mirror your organizational structure (such as team membership or department structure)
300+
* Need to maintain cost center assignments automatically as users change roles or move between teams
301+
302+
### Options for automation
303+
304+
If you decide that automation would benefit your organization, the REST API examples in this tutorial provide the foundation for building custom scripts. For details of other endpoints, see [AUTOTITLE](/rest/enterprise-admin/billing?apiVersion=2022-11-28).
305+
306+
If you want to automate cost centers based on team membership or create a two-tier model for controlling costs of premium requests, [{% data variables.product.github %} Cost Center Automation](https://github.com/github/cost-center-automation?ref_product=copilot&ref_type=engagement&ref_style=text) provides a complete implementation using actions workflows that you can adapt for your needs.
307+
308+
## Next steps
309+
310+
To find out about the endpoints you can use to automate reporting of usage and costs, see [AUTOTITLE](/billing/tutorials/automate-usage-reporting).
311+
312+
If there are any paid products that you want to block all access to, you can disable the feature using an enterprise policy. See [AUTOTITLE](/admin/enforcing-policies/enforcing-policies-for-your-enterprise/about-enterprise-policies).

content/billing/tutorials/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ topics:
1111
children:
1212
- /automate-usage-reporting
1313
- /set-up-budgets
14+
- /control-costs-at-scale
1415
- /use-cost-centers
1516
- /estimate-spending
1617
- /gather-insights
1718
contentType: tutorials
1819
---
19-
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cost centers are available with {% data variables.product.prodname_enterprise %}
2+
<a href="https://github.com/account/enterprises/new?ref_product=ghec&ref_type=trial&ref_style=button&ref_plan=enterprise" target="_blank" class="btn btn-primary mt-3 mr-3 no-underline"><span>Set up a trial of {% data variables.product.prodname_ghe_cloud %}</span> {% octicon "link-external" height:16 aria-label="link-external" %}</a>

data/reusables/rest-api/github-cli-install-and-auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1. Install {% data variables.product.prodname_cli %} on macOS, Windows, or Linux. For more information, see [Installation](https://github.com/cli/cli#installation) in the {% data variables.product.prodname_cli %} repository.
1+
1. Install {% data variables.product.prodname_cli %} on macOS, Windows, or Linux. For more information, see [Installation](https://github.com/cli/cli?ref_product=cli&ref_type=engagement&ref_style=text#installation) in the {% data variables.product.prodname_cli %} repository.
22
1. To authenticate to {% data variables.product.github %}, run the following command from your terminal.
33

44
```shell

src/data-directory/lib/data-schemas/ctas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
type: 'string',
1313
name: 'Product',
1414
description: 'The GitHub product the CTA leads users to',
15-
enum: ['copilot', 'ghec', 'desktop', 'code-quality'],
15+
enum: ['copilot', 'ghec', 'desktop', 'code-quality', 'cli'],
1616
},
1717

1818
// Type of CTA: The type of action the CTA encourages users to take

0 commit comments

Comments
 (0)