You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Restructure pkg/ folder in preparation of new parser
* Implement Setters for ParsedLog
* Rework parser to have uniform interface for parse functions
* Remove test that doesn't apply anymore
* Rework Staus to Created/NotCreated/Failed
* Implement correct parsing of Modify/Destroy
* Add tests for new parsers
* Remove legend and make only Failed red
* Fix go vet issues
* Make Created the default for BeforeStatus
* Parse refreshes as well
* Add more State stats to the stats command
* Only export the necessary functions for other packages
* Adapt docs for new parser
* Various small docs changes after review
* Remove redundant command
* Small improvements to README
* Small improvements to docs
* Small improvements to docs
* Rewrite outdated comment
* Improve comments and clean up
* go fmt
Copy file name to clipboardexpand all lines: docs/stats.md
+12-5
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,29 @@
9
9
10
10
**Arguments:**
11
11
12
-
Log_file: Optional. Instruct `tf-profile` to read input from a text file instead of stdin.
12
+
- log_file: _Optional_. Instruct `tf-profile` to read input from a text file instead of stdin.
13
13
14
14
## Description
15
15
16
16
The following statistics will be printed:
17
17
18
18
General:
19
-
-**Number of resources created**: Number of resources detected in your log.
19
+
-**Number of resources created**: Number of resources detected in your log. Depending on which phases (refresh, plan, apply) were present in the log, this number can differ and may not always match what is defined in your code. For example, doing `terraform apply my_plan_file` will not include a resource that is not to be modified in this plan.
20
20
21
21
Duration:
22
22
-**Cumulative duration**: Cumulative duration of modifications. This is the sum of the duration of all modifications in the logs. Because Terraform modifies resources in parallel, this will typically be more than the actual wall time.
23
-
-**Longest apply time**: Lngest time it took to modify a single resource. The next metric shows which resource that was.
24
-
-**Longest apply resource**: the name of the resource that took the longest to modify.
23
+
-**Longest apply time**: Longest time it took to modify a single resource. The next metric shows which resource that was.
24
+
-**Longest apply resource**: The name of the resource that took the most time to modify.
25
+
26
+
Operations:
27
+
-**Resources marked for operation \<OPERATION\>**: The amount of resources marked for a certain operation. An Operation can be any of: Create, Destroy, Modify, Replace, None. Resources that are consistent with the state, will be marked for operation None.
25
28
26
29
Resource status:
27
-
-**No. resources in state \<STATE\>**: This statistic shows per state how many resources are in that state after the modifications.
30
+
-**Resources in state \<STATE\>**: This statistic shows per state how many resources are in that state after the modifications. In general, resources can be in three states after a Terraform run: Created, NotCreated or Failed.
31
+
32
+
Desired state:
33
+
-**Resources in desired state**: The amount of resources whose `final_state` is equal to their `desired_state`. In a fully applied configuration, this number should be 100%.
34
+
-**Resources not in desired state**: Resources whose desired state was not achieved after this run. This can be due to failed creation, failed deletion or because "upstream" resources were not able to get to their desired state.
28
35
29
36
Modules:
30
37
-**Number of top-level modules**: Number of modules called in the root module.
Copy file name to clipboardexpand all lines: docs/table.md
+33-25
Original file line number
Diff line number
Diff line change
@@ -6,52 +6,60 @@
6
6
7
7
**Options:**
8
8
- -t, --tee: print logs while parsing them. Shorthand for `terraform apply | tee >(tf-profile stats)`
9
-
- -d, --max_depth: aggregate resources nested deeper than `-d` levels into a resource that represents the module at depth `-d`.
9
+
- -d, --max_depth: aggregate resources nested deeper than `-d` levels into a resource that represents the module at depth `-d`.**Not implented yet**
10
10
- -s, --sort: comma-separated key-value pairs that instruct how to sort the output table. Valid values follow the format `column1:(asc|desc),column2:(asc|desc):...`. By default, `tot_time=desc,resource=asc` is used: sort first by descending modification time, second by resource name in alphabetical order.
11
11
12
12
**Arguments:**
13
13
14
-
Log_file: Optional. Instruct `tf-profile` to read input from a text file instead of stdin.
14
+
- log_file: _Optional_. Instruct `tf-profile` to read input from a text file instead of stdin.
15
15
16
16
## Description
17
17
18
-
A table generated based on the log file or input, sorted according to `-s / --sort` and printed to the terminal.
18
+
This command prints a table based on the log file or input, sorted according to `-s / --sort` and printed to the terminal. Useful to inspect properties about individual resources.
19
19
20
20
```
21
-
resource n tot_time idx_creation idx_created status
aws_ssm_parameter.p5 1 0s 4 4 Created Modify Created
28
+
aws_ssm_parameter.p2 1 0s / / Created None Created
27
29
```
28
30
29
31
The column names are lowercase and separated by underscores to allow for easy referencing in the `--sort` option. The meaning of each column is:
30
32
31
-
-**resource**: Name of the resource. In case a resource is created by a `for_each` or `count` statement, resources are aggregated and individual resource identifiers are replaced by an asterisk (*). See
33
+
-**resource**: Name of the resource. In case a resource is created by a `for_each` or `count` statement, resources are aggregated and individual resource identifiers are replaced by an asterisk (*).
32
34
-**n**: Number of resources represented by this resource name. For regular resources, this will be 1. For resourced created with `for_each` or `count`, this number represents the number of resources created in that loop.
33
35
-**tot_time**: Total cumulative time of all resources identified by this resource name. This is typically higher than the actual wall time, as Terraform can modify multiple resources at the same time.
34
-
-**idx_creation**: order in which resource creation_started_. This means that Terraform started by creation the resource with `idx_creation = 0`. That does not guarantee the creation of this resource finished first as well (see `idx_created`).
35
-
-**idx_created**: order in which resource creation_ended_. this means that the resource with `idx_created = 0` was the first resource to be fully creatd.
36
-
-**status**: For single resources, status can be any of: `Started|NotStarted|Created|Failed`. For aggregated resources, status can be any of: `AllCreated|AllFailed|SomeFailed|NoneStarted|AllStarted|SomeStarted`.
37
-
38
-
With resource aggregation, more informative statuses have precedence over less informative statuses. For example, `AllCreated` will be shown over `AllStarted`.
36
+
-**modify_started**: order in which resource modification_started_. This means that Terraform started by modifying the resource with `modify_started = 0`. It does not guarantee the changes to this resource finished first as well (see `modify_ended`). Resources that were already consistent with the desired state do not have this property.
37
+
-**modify_ended**: order in which resource modifications_ended_. This means that the resource with `modify_ended = 0` was the first resource to finish its modifications (either a creation, deletion, modification or replacement). Resources that were already consistent with the desired state do not have this property.
38
+
-**desired_state**: state (Created, NotCreated) that Terraform will try to achieve with this run. For resources to be modified, created or replaced, Created is the desired state. For resources to be destroyed, NotCreated is the desired state.
39
+
-**operation**: the name of the operation the Terraform will use to reconcile the current and desired situation. Operations can be: Create, Destroy, Replace, Modify, None. Resources in the state that are already consistent with the configuration, the operation will be None.
40
+
-**final_state**: Final state of the resource after this run. In addition to Created and NotCreated, Failed is used to indicate the operation failed.
39
41
40
42
## Sorting
41
43
42
44
Any of the columns above can be used to sort the output table, by means of the `--sort` (shorthand `-s`) option. This option follows the format `column1:(asc|desc),column2:(asc|desc):...`. For example:
43
45
-`tot_time=desc,resource=asc`: sort first by total modification time (showing the highest first). For entries with the same modification time, sort alphabetically.
44
-
-`idx_creation=asc`: sort in order of creation, showing the resources that Terraform finished modifying first.
46
+
-`modify_started=asc`: sort in order modifications, showing the resources that Terraform started modifying first.
47
+
-`final_state=asc`: sort by the final state. See below for the sort order.
45
48
46
-
When sorting on resource status (`status`), statuses are mapped onto integers before sorting.
49
+
When sorting on resource status (`desired_state` or `final_state`), statuses are mapped onto integers before sorting.
47
50
48
-
-NotStarted: 0
49
-
-Started: 1
51
+
-Unknown: 0
52
+
-NotCreated: 1
50
53
- Created: 2
51
54
- Failed: 3
52
-
- SomeStarted: 4
53
-
- AllStarted: 5
54
-
- NoneStarted: 6
55
-
- SomeFailed: 7
56
-
- AllFailed: 8
57
-
- AllCreated: 9
55
+
- Tainted: 4
56
+
- Multiple (for aggregated resources): 5
57
+
58
+
When sorting on resource operations (`operation`), these are mapped onto integers as well:
0 commit comments